/*
 *
 *    Copyright (c) 2021 Project CHIP Authors
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

// THIS FILE IS GENERATED BY ZAP

#import <Foundation/Foundation.h>

#import "CHIPDevice.h"
#import "CHIPDevice_Internal.h"
#import "CHIPError_Internal.h"
#import "app/util/af.h"
#import "gen/CHIPClientCallbacks.h"
#import "gen/CHIPClusters.h"
#import "gen/CHIPClustersObjc.h"

#include <lib/support/Span.h>
#include <platform/CHIPDeviceLayer.h>

using namespace ::chip;

class CHIPDefaultSuccessCallbackBridge : public Callback::Callback<DefaultSuccessCallback> {
public:
    CHIPDefaultSuccessCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<DefaultSuccessCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPDefaultSuccessCallbackBridge() {};

    static void CallbackFn(void * context)
    {
        CHIPDefaultSuccessCallbackBridge * callback = reinterpret_cast<CHIPDefaultSuccessCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, nil);
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPDefaultFailureCallbackBridge : public Callback::Callback<DefaultFailureCallback> {
public:
    CHIPDefaultFailureCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<DefaultFailureCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPDefaultFailureCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t status)
    {
        CHIPDefaultFailureCallbackBridge * callback = reinterpret_cast<CHIPDefaultFailureCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                NSError * error = [CHIPError errorForZCLErrorCode:status];
                callback->mHandler(error, nil);
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPStringAttributeCallbackBridge : public Callback::Callback<StringAttributeCallback> {
public:
    CHIPStringAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool octetString, bool keepAlive = false)
        : Callback::Callback<StringAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
        , mOctetString(octetString)
        , mKeepAlive(keepAlive)
    {
    }

    ~CHIPStringAttributeCallbackBridge() {};

    static void CallbackFn(void * context, chip::ByteSpan value)
    {
        NSData * data = [NSData dataWithBytes:value.data() length:value.size()];

        CHIPStringAttributeCallbackBridge * callback = reinterpret_cast<CHIPStringAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                if (callback->mOctetString) {
                    callback->mHandler(nil, @ { @"value" : data });
                } else {
                    NSString * str = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
                    callback->mHandler(nil, @ { @"value" : str });
                }

                if (!callback->mKeepAlive) {
                    callback->Cancel();
                    delete callback;
                }
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
    bool mOctetString;
    bool mKeepAlive;
};

class CHIPBooleanAttributeCallbackBridge : public Callback::Callback<BooleanAttributeCallback> {
public:
    CHIPBooleanAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false)
        : Callback::Callback<BooleanAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
        , mKeepAlive(keepAlive)
    {
    }

    ~CHIPBooleanAttributeCallbackBridge() {};

    static void CallbackFn(void * context, bool value)
    {
        CHIPBooleanAttributeCallbackBridge * callback = reinterpret_cast<CHIPBooleanAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : [NSNumber numberWithBool:value] });
                if (!callback->mKeepAlive) {
                    callback->Cancel();
                    delete callback;
                }
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
    bool mKeepAlive;
};

class CHIPInt8uAttributeCallbackBridge : public Callback::Callback<Int8uAttributeCallback> {
public:
    CHIPInt8uAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false)
        : Callback::Callback<Int8uAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
        , mKeepAlive(keepAlive)
    {
    }

    ~CHIPInt8uAttributeCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t value)
    {
        CHIPInt8uAttributeCallbackBridge * callback = reinterpret_cast<CHIPInt8uAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : [NSNumber numberWithUnsignedChar:value] });
                if (!callback->mKeepAlive) {
                    callback->Cancel();
                    delete callback;
                }
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
    bool mKeepAlive;
};

class CHIPInt8sAttributeCallbackBridge : public Callback::Callback<Int8sAttributeCallback> {
public:
    CHIPInt8sAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false)
        : Callback::Callback<Int8sAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
        , mKeepAlive(keepAlive)
    {
    }

    ~CHIPInt8sAttributeCallbackBridge() {};

    static void CallbackFn(void * context, int8_t value)
    {
        CHIPInt8sAttributeCallbackBridge * callback = reinterpret_cast<CHIPInt8sAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : [NSNumber numberWithChar:value] });
                if (!callback->mKeepAlive) {
                    callback->Cancel();
                    delete callback;
                }
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
    bool mKeepAlive;
};

class CHIPInt16uAttributeCallbackBridge : public Callback::Callback<Int16uAttributeCallback> {
public:
    CHIPInt16uAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false)
        : Callback::Callback<Int16uAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
        , mKeepAlive(keepAlive)
    {
    }

    ~CHIPInt16uAttributeCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t value)
    {
        CHIPInt16uAttributeCallbackBridge * callback = reinterpret_cast<CHIPInt16uAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : [NSNumber numberWithUnsignedShort:value] });
                if (!callback->mKeepAlive) {
                    callback->Cancel();
                    delete callback;
                }
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
    bool mKeepAlive;
};

class CHIPInt16sAttributeCallbackBridge : public Callback::Callback<Int16sAttributeCallback> {
public:
    CHIPInt16sAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false)
        : Callback::Callback<Int16sAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
        , mKeepAlive(keepAlive)
    {
    }

    ~CHIPInt16sAttributeCallbackBridge() {};

    static void CallbackFn(void * context, int16_t value)
    {
        CHIPInt16sAttributeCallbackBridge * callback = reinterpret_cast<CHIPInt16sAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : [NSNumber numberWithShort:value] });
                if (!callback->mKeepAlive) {
                    callback->Cancel();
                    delete callback;
                }
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
    bool mKeepAlive;
};

class CHIPInt32uAttributeCallbackBridge : public Callback::Callback<Int32uAttributeCallback> {
public:
    CHIPInt32uAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false)
        : Callback::Callback<Int32uAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
        , mKeepAlive(keepAlive)
    {
    }

    ~CHIPInt32uAttributeCallbackBridge() {};

    static void CallbackFn(void * context, uint32_t value)
    {
        CHIPInt32uAttributeCallbackBridge * callback = reinterpret_cast<CHIPInt32uAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : [NSNumber numberWithUnsignedLong:value] });
                if (!callback->mKeepAlive) {
                    callback->Cancel();
                    delete callback;
                }
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
    bool mKeepAlive;
};

class CHIPInt32sAttributeCallbackBridge : public Callback::Callback<Int32sAttributeCallback> {
public:
    CHIPInt32sAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false)
        : Callback::Callback<Int32sAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
        , mKeepAlive(keepAlive)
    {
    }

    ~CHIPInt32sAttributeCallbackBridge() {};

    static void CallbackFn(void * context, int32_t value)
    {
        CHIPInt32sAttributeCallbackBridge * callback = reinterpret_cast<CHIPInt32sAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : [NSNumber numberWithLong:value] });
                if (!callback->mKeepAlive) {
                    callback->Cancel();
                    delete callback;
                }
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
    bool mKeepAlive;
};

class CHIPInt64uAttributeCallbackBridge : public Callback::Callback<Int64uAttributeCallback> {
public:
    CHIPInt64uAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false)
        : Callback::Callback<Int64uAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
        , mKeepAlive(keepAlive)
    {
    }

    ~CHIPInt64uAttributeCallbackBridge() {};

    static void CallbackFn(void * context, uint64_t value)
    {
        CHIPInt64uAttributeCallbackBridge * callback = reinterpret_cast<CHIPInt64uAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : [NSNumber numberWithUnsignedLongLong:value] });
                if (!callback->mKeepAlive) {
                    callback->Cancel();
                    delete callback;
                }
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
    bool mKeepAlive;
};

class CHIPInt64sAttributeCallbackBridge : public Callback::Callback<Int64sAttributeCallback> {
public:
    CHIPInt64sAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue, bool keepAlive = false)
        : Callback::Callback<Int64sAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
        , mKeepAlive(keepAlive)
    {
    }

    ~CHIPInt64sAttributeCallbackBridge() {};

    static void CallbackFn(void * context, int64_t value)
    {
        CHIPInt64sAttributeCallbackBridge * callback = reinterpret_cast<CHIPInt64sAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : [NSNumber numberWithLongLong:value] });
                if (!callback->mKeepAlive) {
                    callback->Cancel();
                    delete callback;
                }
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
    bool mKeepAlive;
};

class CHIPAccountLoginClusterGetSetupPINResponseCallbackBridge
    : public Callback::Callback<AccountLoginClusterGetSetupPINResponseCallback> {
public:
    CHIPAccountLoginClusterGetSetupPINResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<AccountLoginClusterGetSetupPINResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPAccountLoginClusterGetSetupPINResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t * setupPIN)
    {
        CHIPAccountLoginClusterGetSetupPINResponseCallbackBridge * callback
            = reinterpret_cast<CHIPAccountLoginClusterGetSetupPINResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"setupPIN" : [NSString stringWithFormat:@"%s", setupPIN],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPApplicationLauncherClusterLaunchAppResponseCallbackBridge
    : public Callback::Callback<ApplicationLauncherClusterLaunchAppResponseCallback> {
public:
    CHIPApplicationLauncherClusterLaunchAppResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<ApplicationLauncherClusterLaunchAppResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPApplicationLauncherClusterLaunchAppResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t * data)
    {
        CHIPApplicationLauncherClusterLaunchAppResponseCallbackBridge * callback
            = reinterpret_cast<CHIPApplicationLauncherClusterLaunchAppResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"data" : [NSString stringWithFormat:@"%s", data],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPContentLauncherClusterLaunchContentResponseCallbackBridge
    : public Callback::Callback<ContentLauncherClusterLaunchContentResponseCallback> {
public:
    CHIPContentLauncherClusterLaunchContentResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<ContentLauncherClusterLaunchContentResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPContentLauncherClusterLaunchContentResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t * data, uint8_t contentLaunchStatus)
    {
        CHIPContentLauncherClusterLaunchContentResponseCallbackBridge * callback
            = reinterpret_cast<CHIPContentLauncherClusterLaunchContentResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"data" : [NSString stringWithFormat:@"%s", data],
                    @"contentLaunchStatus" : [NSNumber numberWithUnsignedChar:contentLaunchStatus],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPContentLauncherClusterLaunchURLResponseCallbackBridge
    : public Callback::Callback<ContentLauncherClusterLaunchURLResponseCallback> {
public:
    CHIPContentLauncherClusterLaunchURLResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<ContentLauncherClusterLaunchURLResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPContentLauncherClusterLaunchURLResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t * data, uint8_t contentLaunchStatus)
    {
        CHIPContentLauncherClusterLaunchURLResponseCallbackBridge * callback
            = reinterpret_cast<CHIPContentLauncherClusterLaunchURLResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"data" : [NSString stringWithFormat:@"%s", data],
                    @"contentLaunchStatus" : [NSNumber numberWithUnsignedChar:contentLaunchStatus],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPDoorLockClusterClearAllPinsResponseCallbackBridge
    : public Callback::Callback<DoorLockClusterClearAllPinsResponseCallback> {
public:
    CHIPDoorLockClusterClearAllPinsResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<DoorLockClusterClearAllPinsResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPDoorLockClusterClearAllPinsResponseCallbackBridge() {};

    static void CallbackFn(void * context)
    {
        CHIPDoorLockClusterClearAllPinsResponseCallbackBridge * callback
            = reinterpret_cast<CHIPDoorLockClusterClearAllPinsResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {});
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPDoorLockClusterClearAllRfidsResponseCallbackBridge
    : public Callback::Callback<DoorLockClusterClearAllRfidsResponseCallback> {
public:
    CHIPDoorLockClusterClearAllRfidsResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<DoorLockClusterClearAllRfidsResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPDoorLockClusterClearAllRfidsResponseCallbackBridge() {};

    static void CallbackFn(void * context)
    {
        CHIPDoorLockClusterClearAllRfidsResponseCallbackBridge * callback
            = reinterpret_cast<CHIPDoorLockClusterClearAllRfidsResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {});
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPDoorLockClusterClearHolidayScheduleResponseCallbackBridge
    : public Callback::Callback<DoorLockClusterClearHolidayScheduleResponseCallback> {
public:
    CHIPDoorLockClusterClearHolidayScheduleResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<DoorLockClusterClearHolidayScheduleResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPDoorLockClusterClearHolidayScheduleResponseCallbackBridge() {};

    static void CallbackFn(void * context)
    {
        CHIPDoorLockClusterClearHolidayScheduleResponseCallbackBridge * callback
            = reinterpret_cast<CHIPDoorLockClusterClearHolidayScheduleResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {});
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPDoorLockClusterClearPinResponseCallbackBridge : public Callback::Callback<DoorLockClusterClearPinResponseCallback> {
public:
    CHIPDoorLockClusterClearPinResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<DoorLockClusterClearPinResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPDoorLockClusterClearPinResponseCallbackBridge() {};

    static void CallbackFn(void * context)
    {
        CHIPDoorLockClusterClearPinResponseCallbackBridge * callback
            = reinterpret_cast<CHIPDoorLockClusterClearPinResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {});
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPDoorLockClusterClearRfidResponseCallbackBridge : public Callback::Callback<DoorLockClusterClearRfidResponseCallback> {
public:
    CHIPDoorLockClusterClearRfidResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<DoorLockClusterClearRfidResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPDoorLockClusterClearRfidResponseCallbackBridge() {};

    static void CallbackFn(void * context)
    {
        CHIPDoorLockClusterClearRfidResponseCallbackBridge * callback
            = reinterpret_cast<CHIPDoorLockClusterClearRfidResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {});
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPDoorLockClusterClearWeekdayScheduleResponseCallbackBridge
    : public Callback::Callback<DoorLockClusterClearWeekdayScheduleResponseCallback> {
public:
    CHIPDoorLockClusterClearWeekdayScheduleResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<DoorLockClusterClearWeekdayScheduleResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPDoorLockClusterClearWeekdayScheduleResponseCallbackBridge() {};

    static void CallbackFn(void * context)
    {
        CHIPDoorLockClusterClearWeekdayScheduleResponseCallbackBridge * callback
            = reinterpret_cast<CHIPDoorLockClusterClearWeekdayScheduleResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {});
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPDoorLockClusterClearYeardayScheduleResponseCallbackBridge
    : public Callback::Callback<DoorLockClusterClearYeardayScheduleResponseCallback> {
public:
    CHIPDoorLockClusterClearYeardayScheduleResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<DoorLockClusterClearYeardayScheduleResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPDoorLockClusterClearYeardayScheduleResponseCallbackBridge() {};

    static void CallbackFn(void * context)
    {
        CHIPDoorLockClusterClearYeardayScheduleResponseCallbackBridge * callback
            = reinterpret_cast<CHIPDoorLockClusterClearYeardayScheduleResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {});
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPDoorLockClusterGetHolidayScheduleResponseCallbackBridge
    : public Callback::Callback<DoorLockClusterGetHolidayScheduleResponseCallback> {
public:
    CHIPDoorLockClusterGetHolidayScheduleResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<DoorLockClusterGetHolidayScheduleResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPDoorLockClusterGetHolidayScheduleResponseCallbackBridge() {};

    static void CallbackFn(
        void * context, uint8_t scheduleId, uint32_t localStartTime, uint32_t localEndTime, uint8_t operatingModeDuringHoliday)
    {
        CHIPDoorLockClusterGetHolidayScheduleResponseCallbackBridge * callback
            = reinterpret_cast<CHIPDoorLockClusterGetHolidayScheduleResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"scheduleId" : [NSNumber numberWithUnsignedChar:scheduleId],
                    @"localStartTime" : [NSNumber numberWithUnsignedLong:localStartTime],
                    @"localEndTime" : [NSNumber numberWithUnsignedLong:localEndTime],
                    @"operatingModeDuringHoliday" : [NSNumber numberWithUnsignedChar:operatingModeDuringHoliday],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPDoorLockClusterGetLogRecordResponseCallbackBridge
    : public Callback::Callback<DoorLockClusterGetLogRecordResponseCallback> {
public:
    CHIPDoorLockClusterGetLogRecordResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<DoorLockClusterGetLogRecordResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPDoorLockClusterGetLogRecordResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t logEntryId, uint32_t timestamp, uint8_t eventType, uint8_t source,
        uint8_t eventIdOrAlarmCode, uint16_t userId, uint8_t * pin)
    {
        CHIPDoorLockClusterGetLogRecordResponseCallbackBridge * callback
            = reinterpret_cast<CHIPDoorLockClusterGetLogRecordResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"logEntryId" : [NSNumber numberWithUnsignedShort:logEntryId],
                    @"timestamp" : [NSNumber numberWithUnsignedLong:timestamp],
                    @"eventType" : [NSNumber numberWithUnsignedChar:eventType],
                    @"source" : [NSNumber numberWithUnsignedChar:source],
                    @"eventIdOrAlarmCode" : [NSNumber numberWithUnsignedChar:eventIdOrAlarmCode],
                    @"userId" : [NSNumber numberWithUnsignedShort:userId],
                    @"pin" : [NSString stringWithFormat:@"%s", pin],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPDoorLockClusterGetPinResponseCallbackBridge : public Callback::Callback<DoorLockClusterGetPinResponseCallback> {
public:
    CHIPDoorLockClusterGetPinResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<DoorLockClusterGetPinResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPDoorLockClusterGetPinResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t userId, uint8_t userStatus, uint8_t userType, uint8_t * pin)
    {
        CHIPDoorLockClusterGetPinResponseCallbackBridge * callback
            = reinterpret_cast<CHIPDoorLockClusterGetPinResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"userId" : [NSNumber numberWithUnsignedShort:userId],
                    @"userStatus" : [NSNumber numberWithUnsignedChar:userStatus],
                    @"userType" : [NSNumber numberWithUnsignedChar:userType],
                    @"pin" : [NSString stringWithFormat:@"%s", pin],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPDoorLockClusterGetRfidResponseCallbackBridge : public Callback::Callback<DoorLockClusterGetRfidResponseCallback> {
public:
    CHIPDoorLockClusterGetRfidResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<DoorLockClusterGetRfidResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPDoorLockClusterGetRfidResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t userId, uint8_t userStatus, uint8_t userType, uint8_t * rfid)
    {
        CHIPDoorLockClusterGetRfidResponseCallbackBridge * callback
            = reinterpret_cast<CHIPDoorLockClusterGetRfidResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"userId" : [NSNumber numberWithUnsignedShort:userId],
                    @"userStatus" : [NSNumber numberWithUnsignedChar:userStatus],
                    @"userType" : [NSNumber numberWithUnsignedChar:userType],
                    @"rfid" : [NSString stringWithFormat:@"%s", rfid],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPDoorLockClusterGetUserTypeResponseCallbackBridge : public Callback::Callback<DoorLockClusterGetUserTypeResponseCallback> {
public:
    CHIPDoorLockClusterGetUserTypeResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<DoorLockClusterGetUserTypeResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPDoorLockClusterGetUserTypeResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t userId, uint8_t userType)
    {
        CHIPDoorLockClusterGetUserTypeResponseCallbackBridge * callback
            = reinterpret_cast<CHIPDoorLockClusterGetUserTypeResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"userId" : [NSNumber numberWithUnsignedShort:userId],
                    @"userType" : [NSNumber numberWithUnsignedChar:userType],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPDoorLockClusterGetWeekdayScheduleResponseCallbackBridge
    : public Callback::Callback<DoorLockClusterGetWeekdayScheduleResponseCallback> {
public:
    CHIPDoorLockClusterGetWeekdayScheduleResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<DoorLockClusterGetWeekdayScheduleResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPDoorLockClusterGetWeekdayScheduleResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t scheduleId, uint16_t userId, uint8_t daysMask, uint8_t startHour,
        uint8_t startMinute, uint8_t endHour, uint8_t endMinute)
    {
        CHIPDoorLockClusterGetWeekdayScheduleResponseCallbackBridge * callback
            = reinterpret_cast<CHIPDoorLockClusterGetWeekdayScheduleResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"scheduleId" : [NSNumber numberWithUnsignedChar:scheduleId],
                    @"userId" : [NSNumber numberWithUnsignedShort:userId],
                    @"daysMask" : [NSNumber numberWithUnsignedChar:daysMask],
                    @"startHour" : [NSNumber numberWithUnsignedChar:startHour],
                    @"startMinute" : [NSNumber numberWithUnsignedChar:startMinute],
                    @"endHour" : [NSNumber numberWithUnsignedChar:endHour],
                    @"endMinute" : [NSNumber numberWithUnsignedChar:endMinute],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPDoorLockClusterGetYeardayScheduleResponseCallbackBridge
    : public Callback::Callback<DoorLockClusterGetYeardayScheduleResponseCallback> {
public:
    CHIPDoorLockClusterGetYeardayScheduleResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<DoorLockClusterGetYeardayScheduleResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPDoorLockClusterGetYeardayScheduleResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t scheduleId, uint16_t userId, uint32_t localStartTime, uint32_t localEndTime)
    {
        CHIPDoorLockClusterGetYeardayScheduleResponseCallbackBridge * callback
            = reinterpret_cast<CHIPDoorLockClusterGetYeardayScheduleResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"scheduleId" : [NSNumber numberWithUnsignedChar:scheduleId],
                    @"userId" : [NSNumber numberWithUnsignedShort:userId],
                    @"localStartTime" : [NSNumber numberWithUnsignedLong:localStartTime],
                    @"localEndTime" : [NSNumber numberWithUnsignedLong:localEndTime],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPDoorLockClusterLockDoorResponseCallbackBridge : public Callback::Callback<DoorLockClusterLockDoorResponseCallback> {
public:
    CHIPDoorLockClusterLockDoorResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<DoorLockClusterLockDoorResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPDoorLockClusterLockDoorResponseCallbackBridge() {};

    static void CallbackFn(void * context)
    {
        CHIPDoorLockClusterLockDoorResponseCallbackBridge * callback
            = reinterpret_cast<CHIPDoorLockClusterLockDoorResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {});
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPDoorLockClusterSetHolidayScheduleResponseCallbackBridge
    : public Callback::Callback<DoorLockClusterSetHolidayScheduleResponseCallback> {
public:
    CHIPDoorLockClusterSetHolidayScheduleResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<DoorLockClusterSetHolidayScheduleResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPDoorLockClusterSetHolidayScheduleResponseCallbackBridge() {};

    static void CallbackFn(void * context)
    {
        CHIPDoorLockClusterSetHolidayScheduleResponseCallbackBridge * callback
            = reinterpret_cast<CHIPDoorLockClusterSetHolidayScheduleResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {});
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPDoorLockClusterSetPinResponseCallbackBridge : public Callback::Callback<DoorLockClusterSetPinResponseCallback> {
public:
    CHIPDoorLockClusterSetPinResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<DoorLockClusterSetPinResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPDoorLockClusterSetPinResponseCallbackBridge() {};

    static void CallbackFn(void * context)
    {
        CHIPDoorLockClusterSetPinResponseCallbackBridge * callback
            = reinterpret_cast<CHIPDoorLockClusterSetPinResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {});
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPDoorLockClusterSetRfidResponseCallbackBridge : public Callback::Callback<DoorLockClusterSetRfidResponseCallback> {
public:
    CHIPDoorLockClusterSetRfidResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<DoorLockClusterSetRfidResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPDoorLockClusterSetRfidResponseCallbackBridge() {};

    static void CallbackFn(void * context)
    {
        CHIPDoorLockClusterSetRfidResponseCallbackBridge * callback
            = reinterpret_cast<CHIPDoorLockClusterSetRfidResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {});
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPDoorLockClusterSetUserTypeResponseCallbackBridge : public Callback::Callback<DoorLockClusterSetUserTypeResponseCallback> {
public:
    CHIPDoorLockClusterSetUserTypeResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<DoorLockClusterSetUserTypeResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPDoorLockClusterSetUserTypeResponseCallbackBridge() {};

    static void CallbackFn(void * context)
    {
        CHIPDoorLockClusterSetUserTypeResponseCallbackBridge * callback
            = reinterpret_cast<CHIPDoorLockClusterSetUserTypeResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {});
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPDoorLockClusterSetWeekdayScheduleResponseCallbackBridge
    : public Callback::Callback<DoorLockClusterSetWeekdayScheduleResponseCallback> {
public:
    CHIPDoorLockClusterSetWeekdayScheduleResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<DoorLockClusterSetWeekdayScheduleResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPDoorLockClusterSetWeekdayScheduleResponseCallbackBridge() {};

    static void CallbackFn(void * context)
    {
        CHIPDoorLockClusterSetWeekdayScheduleResponseCallbackBridge * callback
            = reinterpret_cast<CHIPDoorLockClusterSetWeekdayScheduleResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {});
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPDoorLockClusterSetYeardayScheduleResponseCallbackBridge
    : public Callback::Callback<DoorLockClusterSetYeardayScheduleResponseCallback> {
public:
    CHIPDoorLockClusterSetYeardayScheduleResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<DoorLockClusterSetYeardayScheduleResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPDoorLockClusterSetYeardayScheduleResponseCallbackBridge() {};

    static void CallbackFn(void * context)
    {
        CHIPDoorLockClusterSetYeardayScheduleResponseCallbackBridge * callback
            = reinterpret_cast<CHIPDoorLockClusterSetYeardayScheduleResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {});
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPDoorLockClusterUnlockDoorResponseCallbackBridge : public Callback::Callback<DoorLockClusterUnlockDoorResponseCallback> {
public:
    CHIPDoorLockClusterUnlockDoorResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<DoorLockClusterUnlockDoorResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPDoorLockClusterUnlockDoorResponseCallbackBridge() {};

    static void CallbackFn(void * context)
    {
        CHIPDoorLockClusterUnlockDoorResponseCallbackBridge * callback
            = reinterpret_cast<CHIPDoorLockClusterUnlockDoorResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {});
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPDoorLockClusterUnlockWithTimeoutResponseCallbackBridge
    : public Callback::Callback<DoorLockClusterUnlockWithTimeoutResponseCallback> {
public:
    CHIPDoorLockClusterUnlockWithTimeoutResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<DoorLockClusterUnlockWithTimeoutResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPDoorLockClusterUnlockWithTimeoutResponseCallbackBridge() {};

    static void CallbackFn(void * context)
    {
        CHIPDoorLockClusterUnlockWithTimeoutResponseCallbackBridge * callback
            = reinterpret_cast<CHIPDoorLockClusterUnlockWithTimeoutResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {});
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPGeneralCommissioningClusterArmFailSafeResponseCallbackBridge
    : public Callback::Callback<GeneralCommissioningClusterArmFailSafeResponseCallback> {
public:
    CHIPGeneralCommissioningClusterArmFailSafeResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<GeneralCommissioningClusterArmFailSafeResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPGeneralCommissioningClusterArmFailSafeResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t errorCode, uint8_t * debugText)
    {
        CHIPGeneralCommissioningClusterArmFailSafeResponseCallbackBridge * callback
            = reinterpret_cast<CHIPGeneralCommissioningClusterArmFailSafeResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"errorCode" : [NSNumber numberWithUnsignedChar:errorCode],
                    @"debugText" : [NSString stringWithFormat:@"%s", debugText],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallbackBridge
    : public Callback::Callback<GeneralCommissioningClusterCommissioningCompleteResponseCallback> {
public:
    CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<GeneralCommissioningClusterCommissioningCompleteResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t errorCode, uint8_t * debugText)
    {
        CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallbackBridge * callback
            = reinterpret_cast<CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"errorCode" : [NSNumber numberWithUnsignedChar:errorCode],
                    @"debugText" : [NSString stringWithFormat:@"%s", debugText],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPGeneralCommissioningClusterSetRegulatoryConfigResponseCallbackBridge
    : public Callback::Callback<GeneralCommissioningClusterSetRegulatoryConfigResponseCallback> {
public:
    CHIPGeneralCommissioningClusterSetRegulatoryConfigResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<GeneralCommissioningClusterSetRegulatoryConfigResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPGeneralCommissioningClusterSetRegulatoryConfigResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t errorCode, uint8_t * debugText)
    {
        CHIPGeneralCommissioningClusterSetRegulatoryConfigResponseCallbackBridge * callback
            = reinterpret_cast<CHIPGeneralCommissioningClusterSetRegulatoryConfigResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"errorCode" : [NSNumber numberWithUnsignedChar:errorCode],
                    @"debugText" : [NSString stringWithFormat:@"%s", debugText],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPGroupsClusterAddGroupResponseCallbackBridge : public Callback::Callback<GroupsClusterAddGroupResponseCallback> {
public:
    CHIPGroupsClusterAddGroupResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<GroupsClusterAddGroupResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPGroupsClusterAddGroupResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t groupId)
    {
        CHIPGroupsClusterAddGroupResponseCallbackBridge * callback
            = reinterpret_cast<CHIPGroupsClusterAddGroupResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"groupId" : [NSNumber numberWithUnsignedShort:groupId],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPGroupsClusterGetGroupMembershipResponseCallbackBridge
    : public Callback::Callback<GroupsClusterGetGroupMembershipResponseCallback> {
public:
    CHIPGroupsClusterGetGroupMembershipResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<GroupsClusterGetGroupMembershipResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPGroupsClusterGetGroupMembershipResponseCallbackBridge() {};

    static void CallbackFn(
        void * context, uint8_t capacity, uint8_t groupCount, /* TYPE WARNING: array array defaults to */ uint8_t * groupList)
    {
        CHIPGroupsClusterGetGroupMembershipResponseCallbackBridge * callback
            = reinterpret_cast<CHIPGroupsClusterGetGroupMembershipResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"capacity" : [NSNumber numberWithUnsignedChar:capacity],
                    @"groupCount" : [NSNumber numberWithUnsignedChar:groupCount],
                    // groupList: /* TYPE WARNING: array array defaults to */ uint8_t *
                    // Conversion from this type to Objc is not properly implemented yet
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPGroupsClusterRemoveGroupResponseCallbackBridge : public Callback::Callback<GroupsClusterRemoveGroupResponseCallback> {
public:
    CHIPGroupsClusterRemoveGroupResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<GroupsClusterRemoveGroupResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPGroupsClusterRemoveGroupResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t groupId)
    {
        CHIPGroupsClusterRemoveGroupResponseCallbackBridge * callback
            = reinterpret_cast<CHIPGroupsClusterRemoveGroupResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"groupId" : [NSNumber numberWithUnsignedShort:groupId],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPGroupsClusterViewGroupResponseCallbackBridge : public Callback::Callback<GroupsClusterViewGroupResponseCallback> {
public:
    CHIPGroupsClusterViewGroupResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<GroupsClusterViewGroupResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPGroupsClusterViewGroupResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t groupId, uint8_t * groupName)
    {
        CHIPGroupsClusterViewGroupResponseCallbackBridge * callback
            = reinterpret_cast<CHIPGroupsClusterViewGroupResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"groupId" : [NSNumber numberWithUnsignedShort:groupId],
                    @"groupName" : [NSString stringWithFormat:@"%s", groupName],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPIdentifyClusterIdentifyQueryResponseCallbackBridge
    : public Callback::Callback<IdentifyClusterIdentifyQueryResponseCallback> {
public:
    CHIPIdentifyClusterIdentifyQueryResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<IdentifyClusterIdentifyQueryResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPIdentifyClusterIdentifyQueryResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t timeout)
    {
        CHIPIdentifyClusterIdentifyQueryResponseCallbackBridge * callback
            = reinterpret_cast<CHIPIdentifyClusterIdentifyQueryResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"timeout" : [NSNumber numberWithUnsignedShort:timeout],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPKeypadInputClusterSendKeyResponseCallbackBridge : public Callback::Callback<KeypadInputClusterSendKeyResponseCallback> {
public:
    CHIPKeypadInputClusterSendKeyResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<KeypadInputClusterSendKeyResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPKeypadInputClusterSendKeyResponseCallbackBridge() {};

    static void CallbackFn(void * context)
    {
        CHIPKeypadInputClusterSendKeyResponseCallbackBridge * callback
            = reinterpret_cast<CHIPKeypadInputClusterSendKeyResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {});
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPMediaPlaybackClusterMediaFastForwardResponseCallbackBridge
    : public Callback::Callback<MediaPlaybackClusterMediaFastForwardResponseCallback> {
public:
    CHIPMediaPlaybackClusterMediaFastForwardResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<MediaPlaybackClusterMediaFastForwardResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPMediaPlaybackClusterMediaFastForwardResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t mediaPlaybackStatus)
    {
        CHIPMediaPlaybackClusterMediaFastForwardResponseCallbackBridge * callback
            = reinterpret_cast<CHIPMediaPlaybackClusterMediaFastForwardResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"mediaPlaybackStatus" : [NSNumber numberWithUnsignedChar:mediaPlaybackStatus],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPMediaPlaybackClusterMediaNextResponseCallbackBridge
    : public Callback::Callback<MediaPlaybackClusterMediaNextResponseCallback> {
public:
    CHIPMediaPlaybackClusterMediaNextResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<MediaPlaybackClusterMediaNextResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPMediaPlaybackClusterMediaNextResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t mediaPlaybackStatus)
    {
        CHIPMediaPlaybackClusterMediaNextResponseCallbackBridge * callback
            = reinterpret_cast<CHIPMediaPlaybackClusterMediaNextResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"mediaPlaybackStatus" : [NSNumber numberWithUnsignedChar:mediaPlaybackStatus],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPMediaPlaybackClusterMediaPauseResponseCallbackBridge
    : public Callback::Callback<MediaPlaybackClusterMediaPauseResponseCallback> {
public:
    CHIPMediaPlaybackClusterMediaPauseResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<MediaPlaybackClusterMediaPauseResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPMediaPlaybackClusterMediaPauseResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t mediaPlaybackStatus)
    {
        CHIPMediaPlaybackClusterMediaPauseResponseCallbackBridge * callback
            = reinterpret_cast<CHIPMediaPlaybackClusterMediaPauseResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"mediaPlaybackStatus" : [NSNumber numberWithUnsignedChar:mediaPlaybackStatus],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPMediaPlaybackClusterMediaPlayResponseCallbackBridge
    : public Callback::Callback<MediaPlaybackClusterMediaPlayResponseCallback> {
public:
    CHIPMediaPlaybackClusterMediaPlayResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<MediaPlaybackClusterMediaPlayResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPMediaPlaybackClusterMediaPlayResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t mediaPlaybackStatus)
    {
        CHIPMediaPlaybackClusterMediaPlayResponseCallbackBridge * callback
            = reinterpret_cast<CHIPMediaPlaybackClusterMediaPlayResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"mediaPlaybackStatus" : [NSNumber numberWithUnsignedChar:mediaPlaybackStatus],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPMediaPlaybackClusterMediaPreviousResponseCallbackBridge
    : public Callback::Callback<MediaPlaybackClusterMediaPreviousResponseCallback> {
public:
    CHIPMediaPlaybackClusterMediaPreviousResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<MediaPlaybackClusterMediaPreviousResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPMediaPlaybackClusterMediaPreviousResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t mediaPlaybackStatus)
    {
        CHIPMediaPlaybackClusterMediaPreviousResponseCallbackBridge * callback
            = reinterpret_cast<CHIPMediaPlaybackClusterMediaPreviousResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"mediaPlaybackStatus" : [NSNumber numberWithUnsignedChar:mediaPlaybackStatus],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPMediaPlaybackClusterMediaRewindResponseCallbackBridge
    : public Callback::Callback<MediaPlaybackClusterMediaRewindResponseCallback> {
public:
    CHIPMediaPlaybackClusterMediaRewindResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<MediaPlaybackClusterMediaRewindResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPMediaPlaybackClusterMediaRewindResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t mediaPlaybackStatus)
    {
        CHIPMediaPlaybackClusterMediaRewindResponseCallbackBridge * callback
            = reinterpret_cast<CHIPMediaPlaybackClusterMediaRewindResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"mediaPlaybackStatus" : [NSNumber numberWithUnsignedChar:mediaPlaybackStatus],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPMediaPlaybackClusterMediaSeekResponseCallbackBridge
    : public Callback::Callback<MediaPlaybackClusterMediaSeekResponseCallback> {
public:
    CHIPMediaPlaybackClusterMediaSeekResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<MediaPlaybackClusterMediaSeekResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPMediaPlaybackClusterMediaSeekResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t mediaPlaybackStatus)
    {
        CHIPMediaPlaybackClusterMediaSeekResponseCallbackBridge * callback
            = reinterpret_cast<CHIPMediaPlaybackClusterMediaSeekResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"mediaPlaybackStatus" : [NSNumber numberWithUnsignedChar:mediaPlaybackStatus],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallbackBridge
    : public Callback::Callback<MediaPlaybackClusterMediaSkipBackwardResponseCallback> {
public:
    CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<MediaPlaybackClusterMediaSkipBackwardResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t mediaPlaybackStatus)
    {
        CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallbackBridge * callback
            = reinterpret_cast<CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"mediaPlaybackStatus" : [NSNumber numberWithUnsignedChar:mediaPlaybackStatus],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPMediaPlaybackClusterMediaSkipForwardResponseCallbackBridge
    : public Callback::Callback<MediaPlaybackClusterMediaSkipForwardResponseCallback> {
public:
    CHIPMediaPlaybackClusterMediaSkipForwardResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<MediaPlaybackClusterMediaSkipForwardResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPMediaPlaybackClusterMediaSkipForwardResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t mediaPlaybackStatus)
    {
        CHIPMediaPlaybackClusterMediaSkipForwardResponseCallbackBridge * callback
            = reinterpret_cast<CHIPMediaPlaybackClusterMediaSkipForwardResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"mediaPlaybackStatus" : [NSNumber numberWithUnsignedChar:mediaPlaybackStatus],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPMediaPlaybackClusterMediaStartOverResponseCallbackBridge
    : public Callback::Callback<MediaPlaybackClusterMediaStartOverResponseCallback> {
public:
    CHIPMediaPlaybackClusterMediaStartOverResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<MediaPlaybackClusterMediaStartOverResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPMediaPlaybackClusterMediaStartOverResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t mediaPlaybackStatus)
    {
        CHIPMediaPlaybackClusterMediaStartOverResponseCallbackBridge * callback
            = reinterpret_cast<CHIPMediaPlaybackClusterMediaStartOverResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"mediaPlaybackStatus" : [NSNumber numberWithUnsignedChar:mediaPlaybackStatus],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPMediaPlaybackClusterMediaStopResponseCallbackBridge
    : public Callback::Callback<MediaPlaybackClusterMediaStopResponseCallback> {
public:
    CHIPMediaPlaybackClusterMediaStopResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<MediaPlaybackClusterMediaStopResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPMediaPlaybackClusterMediaStopResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t mediaPlaybackStatus)
    {
        CHIPMediaPlaybackClusterMediaStopResponseCallbackBridge * callback
            = reinterpret_cast<CHIPMediaPlaybackClusterMediaStopResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"mediaPlaybackStatus" : [NSNumber numberWithUnsignedChar:mediaPlaybackStatus],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPNetworkCommissioningClusterAddThreadNetworkResponseCallbackBridge
    : public Callback::Callback<NetworkCommissioningClusterAddThreadNetworkResponseCallback> {
public:
    CHIPNetworkCommissioningClusterAddThreadNetworkResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<NetworkCommissioningClusterAddThreadNetworkResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPNetworkCommissioningClusterAddThreadNetworkResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t errorCode, uint8_t * debugText)
    {
        CHIPNetworkCommissioningClusterAddThreadNetworkResponseCallbackBridge * callback
            = reinterpret_cast<CHIPNetworkCommissioningClusterAddThreadNetworkResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"errorCode" : [NSNumber numberWithUnsignedChar:errorCode],
                    @"debugText" : [NSString stringWithFormat:@"%s", debugText],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPNetworkCommissioningClusterAddWiFiNetworkResponseCallbackBridge
    : public Callback::Callback<NetworkCommissioningClusterAddWiFiNetworkResponseCallback> {
public:
    CHIPNetworkCommissioningClusterAddWiFiNetworkResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<NetworkCommissioningClusterAddWiFiNetworkResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPNetworkCommissioningClusterAddWiFiNetworkResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t errorCode, uint8_t * debugText)
    {
        CHIPNetworkCommissioningClusterAddWiFiNetworkResponseCallbackBridge * callback
            = reinterpret_cast<CHIPNetworkCommissioningClusterAddWiFiNetworkResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"errorCode" : [NSNumber numberWithUnsignedChar:errorCode],
                    @"debugText" : [NSString stringWithFormat:@"%s", debugText],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPNetworkCommissioningClusterDisableNetworkResponseCallbackBridge
    : public Callback::Callback<NetworkCommissioningClusterDisableNetworkResponseCallback> {
public:
    CHIPNetworkCommissioningClusterDisableNetworkResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<NetworkCommissioningClusterDisableNetworkResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPNetworkCommissioningClusterDisableNetworkResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t errorCode, uint8_t * debugText)
    {
        CHIPNetworkCommissioningClusterDisableNetworkResponseCallbackBridge * callback
            = reinterpret_cast<CHIPNetworkCommissioningClusterDisableNetworkResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"errorCode" : [NSNumber numberWithUnsignedChar:errorCode],
                    @"debugText" : [NSString stringWithFormat:@"%s", debugText],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPNetworkCommissioningClusterEnableNetworkResponseCallbackBridge
    : public Callback::Callback<NetworkCommissioningClusterEnableNetworkResponseCallback> {
public:
    CHIPNetworkCommissioningClusterEnableNetworkResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<NetworkCommissioningClusterEnableNetworkResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPNetworkCommissioningClusterEnableNetworkResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t errorCode, uint8_t * debugText)
    {
        CHIPNetworkCommissioningClusterEnableNetworkResponseCallbackBridge * callback
            = reinterpret_cast<CHIPNetworkCommissioningClusterEnableNetworkResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"errorCode" : [NSNumber numberWithUnsignedChar:errorCode],
                    @"debugText" : [NSString stringWithFormat:@"%s", debugText],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPNetworkCommissioningClusterRemoveNetworkResponseCallbackBridge
    : public Callback::Callback<NetworkCommissioningClusterRemoveNetworkResponseCallback> {
public:
    CHIPNetworkCommissioningClusterRemoveNetworkResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<NetworkCommissioningClusterRemoveNetworkResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPNetworkCommissioningClusterRemoveNetworkResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t errorCode, uint8_t * debugText)
    {
        CHIPNetworkCommissioningClusterRemoveNetworkResponseCallbackBridge * callback
            = reinterpret_cast<CHIPNetworkCommissioningClusterRemoveNetworkResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"errorCode" : [NSNumber numberWithUnsignedChar:errorCode],
                    @"debugText" : [NSString stringWithFormat:@"%s", debugText],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPNetworkCommissioningClusterScanNetworksResponseCallbackBridge
    : public Callback::Callback<NetworkCommissioningClusterScanNetworksResponseCallback> {
public:
    CHIPNetworkCommissioningClusterScanNetworksResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<NetworkCommissioningClusterScanNetworksResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPNetworkCommissioningClusterScanNetworksResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t errorCode, uint8_t * debugText,
        /* TYPE WARNING: array array defaults to */ uint8_t * wifiScanResults,
        /* TYPE WARNING: array array defaults to */ uint8_t * threadScanResults)
    {
        CHIPNetworkCommissioningClusterScanNetworksResponseCallbackBridge * callback
            = reinterpret_cast<CHIPNetworkCommissioningClusterScanNetworksResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"errorCode" : [NSNumber numberWithUnsignedChar:errorCode],
                    @"debugText" : [NSString stringWithFormat:@"%s", debugText],
                    // wifiScanResults: /* TYPE WARNING: array array defaults to */ uint8_t *
                    // Conversion from this type to Objc is not properly implemented yet
                    // threadScanResults: /* TYPE WARNING: array array defaults to */ uint8_t *
                    // Conversion from this type to Objc is not properly implemented yet
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPNetworkCommissioningClusterUpdateThreadNetworkResponseCallbackBridge
    : public Callback::Callback<NetworkCommissioningClusterUpdateThreadNetworkResponseCallback> {
public:
    CHIPNetworkCommissioningClusterUpdateThreadNetworkResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<NetworkCommissioningClusterUpdateThreadNetworkResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPNetworkCommissioningClusterUpdateThreadNetworkResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t errorCode, uint8_t * debugText)
    {
        CHIPNetworkCommissioningClusterUpdateThreadNetworkResponseCallbackBridge * callback
            = reinterpret_cast<CHIPNetworkCommissioningClusterUpdateThreadNetworkResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"errorCode" : [NSNumber numberWithUnsignedChar:errorCode],
                    @"debugText" : [NSString stringWithFormat:@"%s", debugText],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPNetworkCommissioningClusterUpdateWiFiNetworkResponseCallbackBridge
    : public Callback::Callback<NetworkCommissioningClusterUpdateWiFiNetworkResponseCallback> {
public:
    CHIPNetworkCommissioningClusterUpdateWiFiNetworkResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<NetworkCommissioningClusterUpdateWiFiNetworkResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPNetworkCommissioningClusterUpdateWiFiNetworkResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t errorCode, uint8_t * debugText)
    {
        CHIPNetworkCommissioningClusterUpdateWiFiNetworkResponseCallbackBridge * callback
            = reinterpret_cast<CHIPNetworkCommissioningClusterUpdateWiFiNetworkResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"errorCode" : [NSNumber numberWithUnsignedChar:errorCode],
                    @"debugText" : [NSString stringWithFormat:@"%s", debugText],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPOtaSoftwareUpdateProviderClusterApplyUpdateRequestResponseCallbackBridge
    : public Callback::Callback<OtaSoftwareUpdateProviderClusterApplyUpdateRequestResponseCallback> {
public:
    CHIPOtaSoftwareUpdateProviderClusterApplyUpdateRequestResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<OtaSoftwareUpdateProviderClusterApplyUpdateRequestResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPOtaSoftwareUpdateProviderClusterApplyUpdateRequestResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t action, uint32_t delayedActionTime)
    {
        CHIPOtaSoftwareUpdateProviderClusterApplyUpdateRequestResponseCallbackBridge * callback
            = reinterpret_cast<CHIPOtaSoftwareUpdateProviderClusterApplyUpdateRequestResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"action" : [NSNumber numberWithUnsignedChar:action],
                    @"delayedActionTime" : [NSNumber numberWithUnsignedLong:delayedActionTime],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPOtaSoftwareUpdateProviderClusterQueryImageResponseCallbackBridge
    : public Callback::Callback<OtaSoftwareUpdateProviderClusterQueryImageResponseCallback> {
public:
    CHIPOtaSoftwareUpdateProviderClusterQueryImageResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<OtaSoftwareUpdateProviderClusterQueryImageResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPOtaSoftwareUpdateProviderClusterQueryImageResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint32_t delayedActionTime, uint8_t * imageURI, uint32_t softwareVersion,
        chip::ByteSpan updateToken, uint8_t userConsentNeeded, chip::ByteSpan metadataForRequestor)
    {
        CHIPOtaSoftwareUpdateProviderClusterQueryImageResponseCallbackBridge * callback
            = reinterpret_cast<CHIPOtaSoftwareUpdateProviderClusterQueryImageResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"delayedActionTime" : [NSNumber numberWithUnsignedLong:delayedActionTime],
                    @"imageURI" : [NSString stringWithFormat:@"%s", imageURI],
                    @"softwareVersion" : [NSNumber numberWithUnsignedLong:softwareVersion],
                    @"updateToken" : [NSData dataWithBytes:updateToken.data() length:updateToken.size()],
                    @"userConsentNeeded" : [NSNumber numberWithUnsignedChar:userConsentNeeded],
                    @"metadataForRequestor" : [NSData dataWithBytes:metadataForRequestor.data() length:metadataForRequestor.size()],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPOperationalCredentialsClusterOpCSRResponseCallbackBridge
    : public Callback::Callback<OperationalCredentialsClusterOpCSRResponseCallback> {
public:
    CHIPOperationalCredentialsClusterOpCSRResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<OperationalCredentialsClusterOpCSRResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPOperationalCredentialsClusterOpCSRResponseCallbackBridge() {};

    static void CallbackFn(void * context, chip::ByteSpan CSR, chip::ByteSpan CSRNonce, chip::ByteSpan VendorReserved1,
        chip::ByteSpan VendorReserved2, chip::ByteSpan VendorReserved3, chip::ByteSpan Signature)
    {
        CHIPOperationalCredentialsClusterOpCSRResponseCallbackBridge * callback
            = reinterpret_cast<CHIPOperationalCredentialsClusterOpCSRResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"CSR" : [NSData dataWithBytes:CSR.data() length:CSR.size()],
                    @"CSRNonce" : [NSData dataWithBytes:CSRNonce.data() length:CSRNonce.size()],
                    @"VendorReserved1" : [NSData dataWithBytes:VendorReserved1.data() length:VendorReserved1.size()],
                    @"VendorReserved2" : [NSData dataWithBytes:VendorReserved2.data() length:VendorReserved2.size()],
                    @"VendorReserved3" : [NSData dataWithBytes:VendorReserved3.data() length:VendorReserved3.size()],
                    @"Signature" : [NSData dataWithBytes:Signature.data() length:Signature.size()],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPOperationalCredentialsClusterOpCertResponseCallbackBridge
    : public Callback::Callback<OperationalCredentialsClusterOpCertResponseCallback> {
public:
    CHIPOperationalCredentialsClusterOpCertResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<OperationalCredentialsClusterOpCertResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPOperationalCredentialsClusterOpCertResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t StatusCode, uint64_t FabricIndex, uint8_t * DebugText)
    {
        CHIPOperationalCredentialsClusterOpCertResponseCallbackBridge * callback
            = reinterpret_cast<CHIPOperationalCredentialsClusterOpCertResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"StatusCode" : [NSNumber numberWithUnsignedChar:StatusCode],
                    @"FabricIndex" : [NSNumber numberWithUnsignedLongLong:FabricIndex],
                    @"DebugText" : [NSString stringWithFormat:@"%s", DebugText],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPOperationalCredentialsClusterSetFabricResponseCallbackBridge
    : public Callback::Callback<OperationalCredentialsClusterSetFabricResponseCallback> {
public:
    CHIPOperationalCredentialsClusterSetFabricResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<OperationalCredentialsClusterSetFabricResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPOperationalCredentialsClusterSetFabricResponseCallbackBridge() {};

    static void CallbackFn(void * context, chip::FabricId FabricId)
    {
        CHIPOperationalCredentialsClusterSetFabricResponseCallbackBridge * callback
            = reinterpret_cast<CHIPOperationalCredentialsClusterSetFabricResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"FabricId" : [NSNumber numberWithUnsignedLongLong:FabricId],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPScenesClusterAddSceneResponseCallbackBridge : public Callback::Callback<ScenesClusterAddSceneResponseCallback> {
public:
    CHIPScenesClusterAddSceneResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<ScenesClusterAddSceneResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPScenesClusterAddSceneResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t groupId, uint8_t sceneId)
    {
        CHIPScenesClusterAddSceneResponseCallbackBridge * callback
            = reinterpret_cast<CHIPScenesClusterAddSceneResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"groupId" : [NSNumber numberWithUnsignedShort:groupId],
                    @"sceneId" : [NSNumber numberWithUnsignedChar:sceneId],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPScenesClusterGetSceneMembershipResponseCallbackBridge
    : public Callback::Callback<ScenesClusterGetSceneMembershipResponseCallback> {
public:
    CHIPScenesClusterGetSceneMembershipResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<ScenesClusterGetSceneMembershipResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPScenesClusterGetSceneMembershipResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t capacity, uint16_t groupId, uint8_t sceneCount,
        /* TYPE WARNING: array array defaults to */ uint8_t * sceneList)
    {
        CHIPScenesClusterGetSceneMembershipResponseCallbackBridge * callback
            = reinterpret_cast<CHIPScenesClusterGetSceneMembershipResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"capacity" : [NSNumber numberWithUnsignedChar:capacity],
                    @"groupId" : [NSNumber numberWithUnsignedShort:groupId],
                    @"sceneCount" : [NSNumber numberWithUnsignedChar:sceneCount],
                    // sceneList: /* TYPE WARNING: array array defaults to */ uint8_t *
                    // Conversion from this type to Objc is not properly implemented yet
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPScenesClusterRemoveAllScenesResponseCallbackBridge
    : public Callback::Callback<ScenesClusterRemoveAllScenesResponseCallback> {
public:
    CHIPScenesClusterRemoveAllScenesResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<ScenesClusterRemoveAllScenesResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPScenesClusterRemoveAllScenesResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t groupId)
    {
        CHIPScenesClusterRemoveAllScenesResponseCallbackBridge * callback
            = reinterpret_cast<CHIPScenesClusterRemoveAllScenesResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"groupId" : [NSNumber numberWithUnsignedShort:groupId],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPScenesClusterRemoveSceneResponseCallbackBridge : public Callback::Callback<ScenesClusterRemoveSceneResponseCallback> {
public:
    CHIPScenesClusterRemoveSceneResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<ScenesClusterRemoveSceneResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPScenesClusterRemoveSceneResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t groupId, uint8_t sceneId)
    {
        CHIPScenesClusterRemoveSceneResponseCallbackBridge * callback
            = reinterpret_cast<CHIPScenesClusterRemoveSceneResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"groupId" : [NSNumber numberWithUnsignedShort:groupId],
                    @"sceneId" : [NSNumber numberWithUnsignedChar:sceneId],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPScenesClusterStoreSceneResponseCallbackBridge : public Callback::Callback<ScenesClusterStoreSceneResponseCallback> {
public:
    CHIPScenesClusterStoreSceneResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<ScenesClusterStoreSceneResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPScenesClusterStoreSceneResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t groupId, uint8_t sceneId)
    {
        CHIPScenesClusterStoreSceneResponseCallbackBridge * callback
            = reinterpret_cast<CHIPScenesClusterStoreSceneResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"groupId" : [NSNumber numberWithUnsignedShort:groupId],
                    @"sceneId" : [NSNumber numberWithUnsignedChar:sceneId],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPScenesClusterViewSceneResponseCallbackBridge : public Callback::Callback<ScenesClusterViewSceneResponseCallback> {
public:
    CHIPScenesClusterViewSceneResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<ScenesClusterViewSceneResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPScenesClusterViewSceneResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t groupId, uint8_t sceneId, uint16_t transitionTime, uint8_t * sceneName,
        /* TYPE WARNING: array array defaults to */ uint8_t * extensionFieldSets)
    {
        CHIPScenesClusterViewSceneResponseCallbackBridge * callback
            = reinterpret_cast<CHIPScenesClusterViewSceneResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"groupId" : [NSNumber numberWithUnsignedShort:groupId],
                    @"sceneId" : [NSNumber numberWithUnsignedChar:sceneId],
                    @"transitionTime" : [NSNumber numberWithUnsignedShort:transitionTime],
                    @"sceneName" : [NSString stringWithFormat:@"%s", sceneName],
                    // extensionFieldSets: /* TYPE WARNING: array array defaults to */ uint8_t *
                    // Conversion from this type to Objc is not properly implemented yet
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPTvChannelClusterChangeChannelResponseCallbackBridge
    : public Callback::Callback<TvChannelClusterChangeChannelResponseCallback> {
public:
    CHIPTvChannelClusterChangeChannelResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<TvChannelClusterChangeChannelResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPTvChannelClusterChangeChannelResponseCallbackBridge() {};

    static void CallbackFn(void * context, /* TYPE WARNING: array array defaults to */ uint8_t * ChannelMatch, uint8_t ErrorType)
    {
        CHIPTvChannelClusterChangeChannelResponseCallbackBridge * callback
            = reinterpret_cast<CHIPTvChannelClusterChangeChannelResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    // ChannelMatch: /* TYPE WARNING: array array defaults to */ uint8_t *
                    // Conversion from this type to Objc is not properly implemented yet
                    @"ErrorType" : [NSNumber numberWithUnsignedChar:ErrorType],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPTargetNavigatorClusterNavigateTargetResponseCallbackBridge
    : public Callback::Callback<TargetNavigatorClusterNavigateTargetResponseCallback> {
public:
    CHIPTargetNavigatorClusterNavigateTargetResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<TargetNavigatorClusterNavigateTargetResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPTargetNavigatorClusterNavigateTargetResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t * data)
    {
        CHIPTargetNavigatorClusterNavigateTargetResponseCallbackBridge * callback
            = reinterpret_cast<CHIPTargetNavigatorClusterNavigateTargetResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"data" : [NSString stringWithFormat:@"%s", data],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPTestClusterClusterTestSpecificResponseCallbackBridge
    : public Callback::Callback<TestClusterClusterTestSpecificResponseCallback> {
public:
    CHIPTestClusterClusterTestSpecificResponseCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<TestClusterClusterTestSpecificResponseCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPTestClusterClusterTestSpecificResponseCallbackBridge() {};

    static void CallbackFn(void * context, uint8_t returnValue)
    {
        CHIPTestClusterClusterTestSpecificResponseCallbackBridge * callback
            = reinterpret_cast<CHIPTestClusterClusterTestSpecificResponseCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ {
                    @"returnValue" : [NSNumber numberWithUnsignedChar:returnValue],
                });
                callback->Cancel();
                delete callback;
            });
        }
    };

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPApplicationLauncherApplicationLauncherListAttributeCallbackBridge
    : public Callback::Callback<ApplicationLauncherApplicationLauncherListListAttributeCallback> {
public:
    CHIPApplicationLauncherApplicationLauncherListAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<ApplicationLauncherApplicationLauncherListListAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPApplicationLauncherApplicationLauncherListAttributeCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t count, uint16_t * entries)
    {
        CHIPApplicationLauncherApplicationLauncherListAttributeCallbackBridge * callback
            = reinterpret_cast<CHIPApplicationLauncherApplicationLauncherListAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            id values[count];
            for (uint16_t i = 0; i < count; i++) {
                values[i] = [NSNumber numberWithUnsignedShort:entries[i]];
            }

            id array = [NSArray arrayWithObjects:values count:count];
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : array });
                callback->Cancel();
                delete callback;
            });
        }
    }

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPAudioOutputAudioOutputListAttributeCallbackBridge
    : public Callback::Callback<AudioOutputAudioOutputListListAttributeCallback> {
public:
    CHIPAudioOutputAudioOutputListAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<AudioOutputAudioOutputListListAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPAudioOutputAudioOutputListAttributeCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t count, _AudioOutputInfo * entries)
    {
        CHIPAudioOutputAudioOutputListAttributeCallbackBridge * callback
            = reinterpret_cast<CHIPAudioOutputAudioOutputListAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            id values[count];
            for (uint16_t i = 0; i < count; i++) {
                values[i] = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithUnsignedChar:entries[i].index],
                                                  @"index", [NSNumber numberWithUnsignedChar:entries[i].outputType], @"outputType",
                                                  [NSData dataWithBytes:entries[i].name.data() length:entries[i].name.size()],
                                                  @"name", nil];
            }

            id array = [NSArray arrayWithObjects:values count:count];
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : array });
                callback->Cancel();
                delete callback;
            });
        }
    }

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPContentLauncherAcceptsHeaderListAttributeCallbackBridge
    : public Callback::Callback<ContentLauncherAcceptsHeaderListListAttributeCallback> {
public:
    CHIPContentLauncherAcceptsHeaderListAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<ContentLauncherAcceptsHeaderListListAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPContentLauncherAcceptsHeaderListAttributeCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t count, chip::ByteSpan * entries)
    {
        CHIPContentLauncherAcceptsHeaderListAttributeCallbackBridge * callback
            = reinterpret_cast<CHIPContentLauncherAcceptsHeaderListAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            id values[count];
            for (uint16_t i = 0; i < count; i++) {
                values[i] = [NSData dataWithBytes:entries[i].data() length:entries[i].size()];
            }

            id array = [NSArray arrayWithObjects:values count:count];
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : array });
                callback->Cancel();
                delete callback;
            });
        }
    }

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPContentLauncherSupportedStreamingTypesAttributeCallbackBridge
    : public Callback::Callback<ContentLauncherSupportedStreamingTypesListAttributeCallback> {
public:
    CHIPContentLauncherSupportedStreamingTypesAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<ContentLauncherSupportedStreamingTypesListAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPContentLauncherSupportedStreamingTypesAttributeCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t count, uint8_t * entries)
    {
        CHIPContentLauncherSupportedStreamingTypesAttributeCallbackBridge * callback
            = reinterpret_cast<CHIPContentLauncherSupportedStreamingTypesAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            id values[count];
            for (uint16_t i = 0; i < count; i++) {
                values[i] = [NSNumber numberWithUnsignedChar:entries[i]];
            }

            id array = [NSArray arrayWithObjects:values count:count];
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : array });
                callback->Cancel();
                delete callback;
            });
        }
    }

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPDescriptorDeviceListAttributeCallbackBridge : public Callback::Callback<DescriptorDeviceListListAttributeCallback> {
public:
    CHIPDescriptorDeviceListAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<DescriptorDeviceListListAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPDescriptorDeviceListAttributeCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t count, _DeviceType * entries)
    {
        CHIPDescriptorDeviceListAttributeCallbackBridge * callback
            = reinterpret_cast<CHIPDescriptorDeviceListAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            id values[count];
            for (uint16_t i = 0; i < count; i++) {
                values[i] = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithUnsignedLong:entries[i].type], @"type",
                                                  [NSNumber numberWithUnsignedShort:entries[i].revision], @"revision", nil];
            }

            id array = [NSArray arrayWithObjects:values count:count];
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : array });
                callback->Cancel();
                delete callback;
            });
        }
    }

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPDescriptorServerListAttributeCallbackBridge : public Callback::Callback<DescriptorServerListListAttributeCallback> {
public:
    CHIPDescriptorServerListAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<DescriptorServerListListAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPDescriptorServerListAttributeCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t count, chip::ClusterId * entries)
    {
        CHIPDescriptorServerListAttributeCallbackBridge * callback
            = reinterpret_cast<CHIPDescriptorServerListAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            id values[count];
            for (uint16_t i = 0; i < count; i++) {
                values[i] = [NSNumber numberWithUnsignedLong:entries[i]];
            }

            id array = [NSArray arrayWithObjects:values count:count];
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : array });
                callback->Cancel();
                delete callback;
            });
        }
    }

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPDescriptorClientListAttributeCallbackBridge : public Callback::Callback<DescriptorClientListListAttributeCallback> {
public:
    CHIPDescriptorClientListAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<DescriptorClientListListAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPDescriptorClientListAttributeCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t count, chip::ClusterId * entries)
    {
        CHIPDescriptorClientListAttributeCallbackBridge * callback
            = reinterpret_cast<CHIPDescriptorClientListAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            id values[count];
            for (uint16_t i = 0; i < count; i++) {
                values[i] = [NSNumber numberWithUnsignedLong:entries[i]];
            }

            id array = [NSArray arrayWithObjects:values count:count];
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : array });
                callback->Cancel();
                delete callback;
            });
        }
    }

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPDescriptorPartsListAttributeCallbackBridge : public Callback::Callback<DescriptorPartsListListAttributeCallback> {
public:
    CHIPDescriptorPartsListAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<DescriptorPartsListListAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPDescriptorPartsListAttributeCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t count, chip::EndpointId * entries)
    {
        CHIPDescriptorPartsListAttributeCallbackBridge * callback
            = reinterpret_cast<CHIPDescriptorPartsListAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            id values[count];
            for (uint16_t i = 0; i < count; i++) {
                values[i] = [NSNumber numberWithUnsignedShort:entries[i]];
            }

            id array = [NSArray arrayWithObjects:values count:count];
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : array });
                callback->Cancel();
                delete callback;
            });
        }
    }

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPFixedLabelLabelListAttributeCallbackBridge : public Callback::Callback<FixedLabelLabelListListAttributeCallback> {
public:
    CHIPFixedLabelLabelListAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<FixedLabelLabelListListAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPFixedLabelLabelListAttributeCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t count, _LabelStruct * entries)
    {
        CHIPFixedLabelLabelListAttributeCallbackBridge * callback
            = reinterpret_cast<CHIPFixedLabelLabelListAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            id values[count];
            for (uint16_t i = 0; i < count; i++) {
                values[i] = [[NSDictionary alloc]
                    initWithObjectsAndKeys:[NSData dataWithBytes:entries[i].label.data() length:entries[i].label.size()], @"label",
                    [NSData dataWithBytes:entries[i].value.data() length:entries[i].value.size()], @"value", nil];
            }

            id array = [NSArray arrayWithObjects:values count:count];
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : array });
                callback->Cancel();
                delete callback;
            });
        }
    }

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPGeneralDiagnosticsNetworkInterfacesAttributeCallbackBridge
    : public Callback::Callback<GeneralDiagnosticsNetworkInterfacesListAttributeCallback> {
public:
    CHIPGeneralDiagnosticsNetworkInterfacesAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<GeneralDiagnosticsNetworkInterfacesListAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPGeneralDiagnosticsNetworkInterfacesAttributeCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t count, _NetworkInterfaceType * entries)
    {
        CHIPGeneralDiagnosticsNetworkInterfacesAttributeCallbackBridge * callback
            = reinterpret_cast<CHIPGeneralDiagnosticsNetworkInterfacesAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            id values[count];
            for (uint16_t i = 0; i < count; i++) {
                values[i] = [[NSDictionary alloc]
                    initWithObjectsAndKeys:[NSData dataWithBytes:entries[i].Name.data() length:entries[i].Name.size()], @"Name",
                    [NSNumber numberWithUnsignedChar:entries[i].FabricConnected], @"FabricConnected",
                    [NSNumber numberWithUnsignedChar:entries[i].OffPremiseServicesReachableIPv4],
                    @"OffPremiseServicesReachableIPv4",
                    [NSNumber numberWithUnsignedChar:entries[i].OffPremiseServicesReachableIPv6],
                    @"OffPremiseServicesReachableIPv6",
                    [NSData dataWithBytes:entries[i].HardwareAddress.data() length:entries[i].HardwareAddress.size()],
                    @"HardwareAddress", [NSNumber numberWithUnsignedChar:entries[i].Type], @"Type", nil];
            }

            id array = [NSArray arrayWithObjects:values count:count];
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : array });
                callback->Cancel();
                delete callback;
            });
        }
    }

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPGroupKeyManagementGroupsAttributeCallbackBridge
    : public Callback::Callback<GroupKeyManagementGroupsListAttributeCallback> {
public:
    CHIPGroupKeyManagementGroupsAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<GroupKeyManagementGroupsListAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPGroupKeyManagementGroupsAttributeCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t count, _GroupState * entries)
    {
        CHIPGroupKeyManagementGroupsAttributeCallbackBridge * callback
            = reinterpret_cast<CHIPGroupKeyManagementGroupsAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            id values[count];
            for (uint16_t i = 0; i < count; i++) {
                values[i] = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithUnsignedShort:entries[i].VendorId],
                                                  @"VendorId", [NSNumber numberWithUnsignedShort:entries[i].VendorGroupId],
                                                  @"VendorGroupId", [NSNumber numberWithUnsignedShort:entries[i].GroupKeySetIndex],
                                                  @"GroupKeySetIndex", nil];
            }

            id array = [NSArray arrayWithObjects:values count:count];
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : array });
                callback->Cancel();
                delete callback;
            });
        }
    }

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPGroupKeyManagementGroupKeysAttributeCallbackBridge
    : public Callback::Callback<GroupKeyManagementGroupKeysListAttributeCallback> {
public:
    CHIPGroupKeyManagementGroupKeysAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<GroupKeyManagementGroupKeysListAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPGroupKeyManagementGroupKeysAttributeCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t count, _GroupKey * entries)
    {
        CHIPGroupKeyManagementGroupKeysAttributeCallbackBridge * callback
            = reinterpret_cast<CHIPGroupKeyManagementGroupKeysAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            id values[count];
            for (uint16_t i = 0; i < count; i++) {
                values[i] = [[NSDictionary alloc]
                    initWithObjectsAndKeys:[NSNumber numberWithUnsignedShort:entries[i].VendorId], @"VendorId",
                    [NSNumber numberWithUnsignedShort:entries[i].GroupKeyIndex], @"GroupKeyIndex",
                    [NSData dataWithBytes:entries[i].GroupKeyRoot.data() length:entries[i].GroupKeyRoot.size()], @"GroupKeyRoot",
                    [NSNumber numberWithUnsignedLongLong:entries[i].GroupKeyEpochStartTime], @"GroupKeyEpochStartTime",
                    [NSNumber numberWithUnsignedChar:entries[i].GroupKeySecurityPolicy], @"GroupKeySecurityPolicy", nil];
            }

            id array = [NSArray arrayWithObjects:values count:count];
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : array });
                callback->Cancel();
                delete callback;
            });
        }
    }

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPMediaInputMediaInputListAttributeCallbackBridge
    : public Callback::Callback<MediaInputMediaInputListListAttributeCallback> {
public:
    CHIPMediaInputMediaInputListAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<MediaInputMediaInputListListAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPMediaInputMediaInputListAttributeCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t count, _MediaInputInfo * entries)
    {
        CHIPMediaInputMediaInputListAttributeCallbackBridge * callback
            = reinterpret_cast<CHIPMediaInputMediaInputListAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            id values[count];
            for (uint16_t i = 0; i < count; i++) {
                values[i] = [[NSDictionary alloc]
                    initWithObjectsAndKeys:[NSNumber numberWithUnsignedChar:entries[i].index], @"index",
                    [NSNumber numberWithUnsignedChar:entries[i].inputType], @"inputType",
                    [NSData dataWithBytes:entries[i].name.data() length:entries[i].name.size()], @"name",
                    [NSData dataWithBytes:entries[i].description.data() length:entries[i].description.size()], @"description", nil];
            }

            id array = [NSArray arrayWithObjects:values count:count];
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : array });
                callback->Cancel();
                delete callback;
            });
        }
    }

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPOperationalCredentialsFabricsListAttributeCallbackBridge
    : public Callback::Callback<OperationalCredentialsFabricsListListAttributeCallback> {
public:
    CHIPOperationalCredentialsFabricsListAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<OperationalCredentialsFabricsListListAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPOperationalCredentialsFabricsListAttributeCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t count, _FabricDescriptor * entries)
    {
        CHIPOperationalCredentialsFabricsListAttributeCallbackBridge * callback
            = reinterpret_cast<CHIPOperationalCredentialsFabricsListAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            id values[count];
            for (uint16_t i = 0; i < count; i++) {
                values[i] = [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithUnsignedLongLong:entries[i].FabricId],
                                                  @"FabricId", [NSNumber numberWithUnsignedShort:entries[i].VendorId], @"VendorId",
                                                  [NSNumber numberWithUnsignedLongLong:entries[i].NodeId], @"NodeId",
                                                  [NSData dataWithBytes:entries[i].Label.data() length:entries[i].Label.size()],
                                                  @"Label", nil];
            }

            id array = [NSArray arrayWithObjects:values count:count];
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : array });
                callback->Cancel();
                delete callback;
            });
        }
    }

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPTvChannelTvChannelListAttributeCallbackBridge : public Callback::Callback<TvChannelTvChannelListListAttributeCallback> {
public:
    CHIPTvChannelTvChannelListAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<TvChannelTvChannelListListAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPTvChannelTvChannelListAttributeCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t count, _TvChannelInfo * entries)
    {
        CHIPTvChannelTvChannelListAttributeCallbackBridge * callback
            = reinterpret_cast<CHIPTvChannelTvChannelListAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            id values[count];
            for (uint16_t i = 0; i < count; i++) {
                values[i] = [[NSDictionary alloc]
                    initWithObjectsAndKeys:[NSNumber numberWithUnsignedShort:entries[i].majorNumber], @"majorNumber",
                    [NSNumber numberWithUnsignedShort:entries[i].minorNumber], @"minorNumber",
                    [NSData dataWithBytes:entries[i].name.data() length:entries[i].name.size()], @"name",
                    [NSData dataWithBytes:entries[i].callSign.data() length:entries[i].callSign.size()], @"callSign",
                    [NSData dataWithBytes:entries[i].affiliateCallSign.data() length:entries[i].affiliateCallSign.size()],
                    @"affiliateCallSign", nil];
            }

            id array = [NSArray arrayWithObjects:values count:count];
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : array });
                callback->Cancel();
                delete callback;
            });
        }
    }

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPTargetNavigatorTargetNavigatorListAttributeCallbackBridge
    : public Callback::Callback<TargetNavigatorTargetNavigatorListListAttributeCallback> {
public:
    CHIPTargetNavigatorTargetNavigatorListAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<TargetNavigatorTargetNavigatorListListAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPTargetNavigatorTargetNavigatorListAttributeCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t count, _NavigateTargetTargetInfo * entries)
    {
        CHIPTargetNavigatorTargetNavigatorListAttributeCallbackBridge * callback
            = reinterpret_cast<CHIPTargetNavigatorTargetNavigatorListAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            id values[count];
            for (uint16_t i = 0; i < count; i++) {
                values[i] = [[NSDictionary alloc]
                    initWithObjectsAndKeys:[NSNumber numberWithUnsignedChar:entries[i].identifier], @"identifier",
                    [NSData dataWithBytes:entries[i].name.data() length:entries[i].name.size()], @"name", nil];
            }

            id array = [NSArray arrayWithObjects:values count:count];
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : array });
                callback->Cancel();
                delete callback;
            });
        }
    }

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPTestClusterListInt8uAttributeCallbackBridge : public Callback::Callback<TestClusterListInt8uListAttributeCallback> {
public:
    CHIPTestClusterListInt8uAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<TestClusterListInt8uListAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPTestClusterListInt8uAttributeCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t count, uint8_t * entries)
    {
        CHIPTestClusterListInt8uAttributeCallbackBridge * callback
            = reinterpret_cast<CHIPTestClusterListInt8uAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            id values[count];
            for (uint16_t i = 0; i < count; i++) {
                values[i] = [NSNumber numberWithUnsignedChar:entries[i]];
            }

            id array = [NSArray arrayWithObjects:values count:count];
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : array });
                callback->Cancel();
                delete callback;
            });
        }
    }

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPTestClusterListOctetStringAttributeCallbackBridge
    : public Callback::Callback<TestClusterListOctetStringListAttributeCallback> {
public:
    CHIPTestClusterListOctetStringAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<TestClusterListOctetStringListAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPTestClusterListOctetStringAttributeCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t count, chip::ByteSpan * entries)
    {
        CHIPTestClusterListOctetStringAttributeCallbackBridge * callback
            = reinterpret_cast<CHIPTestClusterListOctetStringAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            id values[count];
            for (uint16_t i = 0; i < count; i++) {
                values[i] = [NSData dataWithBytes:entries[i].data() length:entries[i].size()];
            }

            id array = [NSArray arrayWithObjects:values count:count];
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : array });
                callback->Cancel();
                delete callback;
            });
        }
    }

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPTestClusterListStructOctetStringAttributeCallbackBridge
    : public Callback::Callback<TestClusterListStructOctetStringListAttributeCallback> {
public:
    CHIPTestClusterListStructOctetStringAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<TestClusterListStructOctetStringListAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPTestClusterListStructOctetStringAttributeCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t count, _TestListStructOctet * entries)
    {
        CHIPTestClusterListStructOctetStringAttributeCallbackBridge * callback
            = reinterpret_cast<CHIPTestClusterListStructOctetStringAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            id values[count];
            for (uint16_t i = 0; i < count; i++) {
                values[i] = [[NSDictionary alloc]
                    initWithObjectsAndKeys:[NSNumber numberWithUnsignedLongLong:entries[i].fabricIndex], @"fabricIndex",
                    [NSData dataWithBytes:entries[i].operationalCert.data() length:entries[i].operationalCert.size()],
                    @"operationalCert", nil];
            }

            id array = [NSArray arrayWithObjects:values count:count];
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : array });
                callback->Cancel();
                delete callback;
            });
        }
    }

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPThreadNetworkDiagnosticsNeighborTableListAttributeCallbackBridge
    : public Callback::Callback<ThreadNetworkDiagnosticsNeighborTableListListAttributeCallback> {
public:
    CHIPThreadNetworkDiagnosticsNeighborTableListAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<ThreadNetworkDiagnosticsNeighborTableListListAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPThreadNetworkDiagnosticsNeighborTableListAttributeCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t count, _NeighborTable * entries)
    {
        CHIPThreadNetworkDiagnosticsNeighborTableListAttributeCallbackBridge * callback
            = reinterpret_cast<CHIPThreadNetworkDiagnosticsNeighborTableListAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            id values[count];
            for (uint16_t i = 0; i < count; i++) {
                values[i] = [[NSDictionary alloc]
                    initWithObjectsAndKeys:[NSNumber numberWithUnsignedLongLong:entries[i].ExtAddress], @"ExtAddress",
                    [NSNumber numberWithUnsignedLong:entries[i].Age], @"Age", [NSNumber numberWithUnsignedShort:entries[i].Rloc16],
                    @"Rloc16", [NSNumber numberWithUnsignedLong:entries[i].LinkFrameCounter], @"LinkFrameCounter",
                    [NSNumber numberWithUnsignedLong:entries[i].MleFrameCounter], @"MleFrameCounter",
                    [NSNumber numberWithUnsignedChar:entries[i].LQI], @"LQI", [NSNumber numberWithChar:entries[i].AverageRssi],
                    @"AverageRssi", [NSNumber numberWithChar:entries[i].LastRssi], @"LastRssi",
                    [NSNumber numberWithUnsignedChar:entries[i].FrameErrorRate], @"FrameErrorRate",
                    [NSNumber numberWithUnsignedChar:entries[i].MessageErrorRate], @"MessageErrorRate",
                    [NSNumber numberWithUnsignedChar:entries[i].RxOnWhenIdle], @"RxOnWhenIdle",
                    [NSNumber numberWithUnsignedChar:entries[i].FullThreadDevice], @"FullThreadDevice",
                    [NSNumber numberWithUnsignedChar:entries[i].FullNetworkData], @"FullNetworkData",
                    [NSNumber numberWithUnsignedChar:entries[i].IsChild], @"IsChild", nil];
            }

            id array = [NSArray arrayWithObjects:values count:count];
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : array });
                callback->Cancel();
                delete callback;
            });
        }
    }

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPThreadNetworkDiagnosticsRouteTableListAttributeCallbackBridge
    : public Callback::Callback<ThreadNetworkDiagnosticsRouteTableListListAttributeCallback> {
public:
    CHIPThreadNetworkDiagnosticsRouteTableListAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<ThreadNetworkDiagnosticsRouteTableListListAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPThreadNetworkDiagnosticsRouteTableListAttributeCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t count, _RouteTable * entries)
    {
        CHIPThreadNetworkDiagnosticsRouteTableListAttributeCallbackBridge * callback
            = reinterpret_cast<CHIPThreadNetworkDiagnosticsRouteTableListAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            id values[count];
            for (uint16_t i = 0; i < count; i++) {
                values[i] =
                    [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithUnsignedLongLong:entries[i].ExtAddress],
                                          @"ExtAddress", [NSNumber numberWithUnsignedShort:entries[i].Rloc16], @"Rloc16",
                                          [NSNumber numberWithUnsignedChar:entries[i].RouterId], @"RouterId",
                                          [NSNumber numberWithUnsignedChar:entries[i].NextHop], @"NextHop",
                                          [NSNumber numberWithUnsignedChar:entries[i].PathCost], @"PathCost",
                                          [NSNumber numberWithUnsignedChar:entries[i].LQIIn], @"LQIIn",
                                          [NSNumber numberWithUnsignedChar:entries[i].LQIOut], @"LQIOut",
                                          [NSNumber numberWithUnsignedChar:entries[i].Age], @"Age",
                                          [NSNumber numberWithUnsignedChar:entries[i].Allocated], @"Allocated",
                                          [NSNumber numberWithUnsignedChar:entries[i].LinkEstablished], @"LinkEstablished", nil];
            }

            id array = [NSArray arrayWithObjects:values count:count];
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : array });
                callback->Cancel();
                delete callback;
            });
        }
    }

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPThreadNetworkDiagnosticsSecurityPolicyAttributeCallbackBridge
    : public Callback::Callback<ThreadNetworkDiagnosticsSecurityPolicyListAttributeCallback> {
public:
    CHIPThreadNetworkDiagnosticsSecurityPolicyAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<ThreadNetworkDiagnosticsSecurityPolicyListAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPThreadNetworkDiagnosticsSecurityPolicyAttributeCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t count, _SecurityPolicy * entries)
    {
        CHIPThreadNetworkDiagnosticsSecurityPolicyAttributeCallbackBridge * callback
            = reinterpret_cast<CHIPThreadNetworkDiagnosticsSecurityPolicyAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            id values[count];
            for (uint16_t i = 0; i < count; i++) {
                values[i] =
                    [[NSDictionary alloc] initWithObjectsAndKeys:[NSNumber numberWithUnsignedShort:entries[i].RotationTime],
                                          @"RotationTime", [NSNumber numberWithUnsignedChar:entries[i].Flags], @"Flags", nil];
            }

            id array = [NSArray arrayWithObjects:values count:count];
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : array });
                callback->Cancel();
                delete callback;
            });
        }
    }

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPThreadNetworkDiagnosticsOperationalDatasetComponentsAttributeCallbackBridge
    : public Callback::Callback<ThreadNetworkDiagnosticsOperationalDatasetComponentsListAttributeCallback> {
public:
    CHIPThreadNetworkDiagnosticsOperationalDatasetComponentsAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<ThreadNetworkDiagnosticsOperationalDatasetComponentsListAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPThreadNetworkDiagnosticsOperationalDatasetComponentsAttributeCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t count, _OperationalDatasetComponents * entries)
    {
        CHIPThreadNetworkDiagnosticsOperationalDatasetComponentsAttributeCallbackBridge * callback
            = reinterpret_cast<CHIPThreadNetworkDiagnosticsOperationalDatasetComponentsAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            id values[count];
            for (uint16_t i = 0; i < count; i++) {
                values[i] = [[NSDictionary alloc]
                    initWithObjectsAndKeys:[NSNumber numberWithUnsignedChar:entries[i].ActiveTimestampPresent],
                    @"ActiveTimestampPresent", [NSNumber numberWithUnsignedChar:entries[i].PendingTimestampPresent],
                    @"PendingTimestampPresent", [NSNumber numberWithUnsignedChar:entries[i].MasterKeyPresent], @"MasterKeyPresent",
                    [NSNumber numberWithUnsignedChar:entries[i].NetworkNamePresent], @"NetworkNamePresent",
                    [NSNumber numberWithUnsignedChar:entries[i].ExtendedPanIdPresent], @"ExtendedPanIdPresent",
                    [NSNumber numberWithUnsignedChar:entries[i].MeshLocalPrefixPresent], @"MeshLocalPrefixPresent",
                    [NSNumber numberWithUnsignedChar:entries[i].DelayPresent], @"DelayPresent",
                    [NSNumber numberWithUnsignedChar:entries[i].PanIdPresent], @"PanIdPresent",
                    [NSNumber numberWithUnsignedChar:entries[i].ChannelPresent], @"ChannelPresent",
                    [NSNumber numberWithUnsignedChar:entries[i].PskcPresent], @"PskcPresent",
                    [NSNumber numberWithUnsignedChar:entries[i].SecurityPolicyPresent], @"SecurityPolicyPresent",
                    [NSNumber numberWithUnsignedChar:entries[i].ChannelMaskPresent], @"ChannelMaskPresent", nil];
            }

            id array = [NSArray arrayWithObjects:values count:count];
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : array });
                callback->Cancel();
                delete callback;
            });
        }
    }

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

class CHIPThreadNetworkDiagnosticsActiveNetworkFaultsListAttributeCallbackBridge
    : public Callback::Callback<ThreadNetworkDiagnosticsActiveNetworkFaultsListListAttributeCallback> {
public:
    CHIPThreadNetworkDiagnosticsActiveNetworkFaultsListAttributeCallbackBridge(ResponseHandler handler, dispatch_queue_t queue)
        : Callback::Callback<ThreadNetworkDiagnosticsActiveNetworkFaultsListListAttributeCallback>(CallbackFn, this)
        , mHandler(handler)
        , mQueue(queue)
    {
    }

    ~CHIPThreadNetworkDiagnosticsActiveNetworkFaultsListAttributeCallbackBridge() {};

    static void CallbackFn(void * context, uint16_t count, uint8_t * entries)
    {
        CHIPThreadNetworkDiagnosticsActiveNetworkFaultsListAttributeCallbackBridge * callback
            = reinterpret_cast<CHIPThreadNetworkDiagnosticsActiveNetworkFaultsListAttributeCallbackBridge *>(context);
        if (callback && callback->mQueue) {
            id values[count];
            for (uint16_t i = 0; i < count; i++) {
                values[i] = [NSNumber numberWithUnsignedChar:entries[i]];
            }

            id array = [NSArray arrayWithObjects:values count:count];
            dispatch_async(callback->mQueue, ^{
                callback->mHandler(nil, @ { @"value" : array });
                callback->Cancel();
                delete callback;
            });
        }
    }

private:
    ResponseHandler mHandler;
    dispatch_queue_t mQueue;
};

@interface CHIPCluster ()
@property (readonly, nonatomic) dispatch_queue_t callbackQueue;
@property (readonly, nonatomic) dispatch_queue_t chipWorkQueue;
- (Controller::ClusterBase *)getCluster;
@end

@implementation CHIPCluster
- (instancetype)initWithDevice:(CHIPDevice *)device endpoint:(EndpointId)endpoint queue:(dispatch_queue_t)queue
{
    if (self = [super init]) {
        Controller::ClusterBase * cppCluster = [self getCluster];
        if (cppCluster == nullptr) {
            return nil;
        }

        if (device == nullptr) {
            return nil;
        }

        CHIP_ERROR err = cppCluster->Associate([device internalDevice], endpoint);
        if (err != CHIP_NO_ERROR) {
            return nil;
        }

        _chipWorkQueue = chip::DeviceLayer::PlatformMgrImpl().GetWorkQueue();
        if (_chipWorkQueue == nil) {
            return nil;
        }

        _callbackQueue = queue;
    }
    return self;
}

- (Controller::ClusterBase *)getCluster
{
    return nullptr;
}
@end

@interface CHIPAccountLogin ()
@property (readonly) Controller::AccountLoginCluster cppCluster;
@end

@implementation CHIPAccountLogin

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)getSetupPIN:(NSString *)tempAccountIdentifier responseHandler:(ResponseHandler)responseHandler
{
    CHIPAccountLoginClusterGetSetupPINResponseCallbackBridge * onSuccess
        = new CHIPAccountLoginClusterGetSetupPINResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.GetSetupPIN(onSuccess->Cancel(), onFailure->Cancel(),
            chip::ByteSpan((const uint8_t *) [tempAccountIdentifier dataUsingEncoding:NSUTF8StringEncoding].bytes,
                [tempAccountIdentifier lengthOfBytesUsingEncoding:NSUTF8StringEncoding]));
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)login:(NSString *)tempAccountIdentifier setupPIN:(NSString *)setupPIN responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.Login(onSuccess->Cancel(), onFailure->Cancel(),
            chip::ByteSpan((const uint8_t *) [tempAccountIdentifier dataUsingEncoding:NSUTF8StringEncoding].bytes,
                [tempAccountIdentifier lengthOfBytesUsingEncoding:NSUTF8StringEncoding]),
            chip::ByteSpan((const uint8_t *) [setupPIN dataUsingEncoding:NSUTF8StringEncoding].bytes,
                [setupPIN lengthOfBytesUsingEncoding:NSUTF8StringEncoding]));
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPApplicationBasic ()
@property (readonly) Controller::ApplicationBasicCluster cppCluster;
@end

@implementation CHIPApplicationBasic

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)changeStatus:(uint8_t)status responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ChangeStatus(onSuccess->Cancel(), onFailure->Cancel(), status);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeVendorNameWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], false);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeVendorName(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeVendorIdWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeVendorId(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeApplicationNameWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], false);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeApplicationName(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeProductIdWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeProductId(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeApplicationIdWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], false);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeApplicationId(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeCatalogVendorIdWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeCatalogVendorId(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeApplicationStatusWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeApplicationStatus(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPApplicationLauncher ()
@property (readonly) Controller::ApplicationLauncherCluster cppCluster;
@end

@implementation CHIPApplicationLauncher

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)launchApp:(NSString *)data
    catalogVendorId:(uint16_t)catalogVendorId
      applicationId:(NSString *)applicationId
    responseHandler:(ResponseHandler)responseHandler
{
    CHIPApplicationLauncherClusterLaunchAppResponseCallbackBridge * onSuccess
        = new CHIPApplicationLauncherClusterLaunchAppResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.LaunchApp(onSuccess->Cancel(), onFailure->Cancel(),
            chip::ByteSpan((const uint8_t *) [data dataUsingEncoding:NSUTF8StringEncoding].bytes,
                [data lengthOfBytesUsingEncoding:NSUTF8StringEncoding]),
            catalogVendorId,
            chip::ByteSpan((const uint8_t *) [applicationId dataUsingEncoding:NSUTF8StringEncoding].bytes,
                [applicationId lengthOfBytesUsingEncoding:NSUTF8StringEncoding]));
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeApplicationLauncherListWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPApplicationLauncherApplicationLauncherListAttributeCallbackBridge * onSuccess
        = new CHIPApplicationLauncherApplicationLauncherListAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeApplicationLauncherList(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeCatalogVendorIdWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeCatalogVendorId(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeApplicationIdWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeApplicationId(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPAudioOutput ()
@property (readonly) Controller::AudioOutputCluster cppCluster;
@end

@implementation CHIPAudioOutput

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)renameOutput:(uint8_t)index name:(NSString *)name responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.RenameOutput(onSuccess->Cancel(), onFailure->Cancel(), index,
            chip::ByteSpan((const uint8_t *) [name dataUsingEncoding:NSUTF8StringEncoding].bytes,
                [name lengthOfBytesUsingEncoding:NSUTF8StringEncoding]));
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)selectOutput:(uint8_t)index responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.SelectOutput(onSuccess->Cancel(), onFailure->Cancel(), index);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeAudioOutputListWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPAudioOutputAudioOutputListAttributeCallbackBridge * onSuccess
        = new CHIPAudioOutputAudioOutputListAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeAudioOutputList(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeCurrentAudioOutputWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeCurrentAudioOutput(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPBarrierControl ()
@property (readonly) Controller::BarrierControlCluster cppCluster;
@end

@implementation CHIPBarrierControl

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)barrierControlGoToPercent:(uint8_t)percentOpen responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.BarrierControlGoToPercent(onSuccess->Cancel(), onFailure->Cancel(), percentOpen);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)barrierControlStop:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.BarrierControlStop(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeBarrierMovingStateWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeBarrierMovingState(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeBarrierSafetyStatusWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeBarrierSafetyStatus(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeBarrierCapabilitiesWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeBarrierCapabilities(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeBarrierPositionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeBarrierPosition(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPBasic ()
@property (readonly) Controller::BasicCluster cppCluster;
@end

@implementation CHIPBasic

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)mfgSpecificPing:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.MfgSpecificPing(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeInteractionModelVersionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeInteractionModelVersion(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeVendorNameWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], false);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeVendorName(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeVendorIDWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeVendorID(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeProductNameWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], false);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeProductName(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeProductIDWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeProductID(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeUserLabelWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], false);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeUserLabel(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeUserLabelWithValue:(NSString *)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding];
        err = self.cppCluster.WriteAttributeUserLabel(
            onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length));
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeLocationWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], false);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeLocation(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeLocationWithValue:(NSString *)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding];
        err = self.cppCluster.WriteAttributeLocation(
            onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length));
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeHardwareVersionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeHardwareVersion(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeHardwareVersionStringWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], false);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeHardwareVersionString(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeSoftwareVersionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeSoftwareVersion(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeSoftwareVersionStringWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], false);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeSoftwareVersionString(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeManufacturingDateWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], false);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeManufacturingDate(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributePartNumberWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], false);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributePartNumber(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeProductURLWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], false);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeProductURL(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeProductLabelWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], false);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeProductLabel(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeSerialNumberWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], false);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeSerialNumber(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeLocalConfigDisabledWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPBooleanAttributeCallbackBridge * onSuccess = new CHIPBooleanAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeLocalConfigDisabled(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeLocalConfigDisabledWithValue:(uint8_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeLocalConfigDisabled(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeReachableWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPBooleanAttributeCallbackBridge * onSuccess = new CHIPBooleanAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeReachable(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPBinaryInputBasic ()
@property (readonly) Controller::BinaryInputBasicCluster cppCluster;
@end

@implementation CHIPBinaryInputBasic

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)readAttributeOutOfServiceWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPBooleanAttributeCallbackBridge * onSuccess = new CHIPBooleanAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeOutOfService(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeOutOfServiceWithValue:(uint8_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeOutOfService(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributePresentValueWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPBooleanAttributeCallbackBridge * onSuccess = new CHIPBooleanAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributePresentValue(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributePresentValueWithValue:(uint8_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributePresentValue(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)configureAttributePresentValueWithMinInterval:(uint16_t)minInterval
                                          maxInterval:(uint16_t)maxInterval
                                      responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ConfigureAttributePresentValue(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)reportAttributePresentValueWithResponseHandler:(ResponseHandler)reportHandler
{
    CHIPBooleanAttributeCallbackBridge * onReport
        = new CHIPBooleanAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
    if (!onReport) {
        reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReportAttributePresentValue(onReport->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onReport;
        reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeStatusFlagsWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeStatusFlags(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)configureAttributeStatusFlagsWithMinInterval:(uint16_t)minInterval
                                         maxInterval:(uint16_t)maxInterval
                                     responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ConfigureAttributeStatusFlags(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)reportAttributeStatusFlagsWithResponseHandler:(ResponseHandler)reportHandler
{
    CHIPInt8uAttributeCallbackBridge * onReport = new CHIPInt8uAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
    if (!onReport) {
        reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReportAttributeStatusFlags(onReport->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onReport;
        reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPBinding ()
@property (readonly) Controller::BindingCluster cppCluster;
@end

@implementation CHIPBinding

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)bind:(uint64_t)nodeId
            groupId:(uint16_t)groupId
         endpointId:(uint16_t)endpointId
          clusterId:(uint32_t)clusterId
    responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.Bind(onSuccess->Cancel(), onFailure->Cancel(), nodeId, groupId, endpointId, clusterId);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)unbind:(uint64_t)nodeId
            groupId:(uint16_t)groupId
         endpointId:(uint16_t)endpointId
          clusterId:(uint32_t)clusterId
    responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.Unbind(onSuccess->Cancel(), onFailure->Cancel(), nodeId, groupId, endpointId, clusterId);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPBridgedDeviceBasic ()
@property (readonly) Controller::BridgedDeviceBasicCluster cppCluster;
@end

@implementation CHIPBridgedDeviceBasic

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)readAttributeVendorNameWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], false);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeVendorName(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeVendorIDWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeVendorID(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeProductNameWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], false);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeProductName(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeUserLabelWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], false);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeUserLabel(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeUserLabelWithValue:(NSString *)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding];
        err = self.cppCluster.WriteAttributeUserLabel(
            onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length));
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeHardwareVersionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeHardwareVersion(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeHardwareVersionStringWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], false);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeHardwareVersionString(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeSoftwareVersionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeSoftwareVersion(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeSoftwareVersionStringWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], false);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeSoftwareVersionString(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeManufacturingDateWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], false);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeManufacturingDate(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributePartNumberWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], false);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributePartNumber(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeProductURLWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], false);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeProductURL(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeProductLabelWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], false);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeProductLabel(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeSerialNumberWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], false);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeSerialNumber(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeReachableWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPBooleanAttributeCallbackBridge * onSuccess = new CHIPBooleanAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeReachable(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPColorControl ()
@property (readonly) Controller::ColorControlCluster cppCluster;
@end

@implementation CHIPColorControl

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)colorLoopSet:(uint8_t)updateFlags
              action:(uint8_t)action
           direction:(uint8_t)direction
                time:(uint16_t)time
            startHue:(uint16_t)startHue
         optionsMask:(uint8_t)optionsMask
     optionsOverride:(uint8_t)optionsOverride
     responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ColorLoopSet(
            onSuccess->Cancel(), onFailure->Cancel(), updateFlags, action, direction, time, startHue, optionsMask, optionsOverride);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)enhancedMoveHue:(uint8_t)moveMode
                   rate:(uint16_t)rate
            optionsMask:(uint8_t)optionsMask
        optionsOverride:(uint8_t)optionsOverride
        responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.EnhancedMoveHue(
            onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionsMask, optionsOverride);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)enhancedMoveToHue:(uint16_t)enhancedHue
                direction:(uint8_t)direction
           transitionTime:(uint16_t)transitionTime
              optionsMask:(uint8_t)optionsMask
          optionsOverride:(uint8_t)optionsOverride
          responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.EnhancedMoveToHue(
            onSuccess->Cancel(), onFailure->Cancel(), enhancedHue, direction, transitionTime, optionsMask, optionsOverride);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)enhancedMoveToHueAndSaturation:(uint16_t)enhancedHue
                            saturation:(uint8_t)saturation
                        transitionTime:(uint16_t)transitionTime
                           optionsMask:(uint8_t)optionsMask
                       optionsOverride:(uint8_t)optionsOverride
                       responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.EnhancedMoveToHueAndSaturation(
            onSuccess->Cancel(), onFailure->Cancel(), enhancedHue, saturation, transitionTime, optionsMask, optionsOverride);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)enhancedStepHue:(uint8_t)stepMode
               stepSize:(uint16_t)stepSize
         transitionTime:(uint16_t)transitionTime
            optionsMask:(uint8_t)optionsMask
        optionsOverride:(uint8_t)optionsOverride
        responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.EnhancedStepHue(
            onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionsMask, optionsOverride);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)moveColor:(int16_t)rateX
              rateY:(int16_t)rateY
        optionsMask:(uint8_t)optionsMask
    optionsOverride:(uint8_t)optionsOverride
    responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.MoveColor(onSuccess->Cancel(), onFailure->Cancel(), rateX, rateY, optionsMask, optionsOverride);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)moveColorTemperature:(uint8_t)moveMode
                        rate:(uint16_t)rate
     colorTemperatureMinimum:(uint16_t)colorTemperatureMinimum
     colorTemperatureMaximum:(uint16_t)colorTemperatureMaximum
                 optionsMask:(uint8_t)optionsMask
             optionsOverride:(uint8_t)optionsOverride
             responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.MoveColorTemperature(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate,
            colorTemperatureMinimum, colorTemperatureMaximum, optionsMask, optionsOverride);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)moveHue:(uint8_t)moveMode
               rate:(uint8_t)rate
        optionsMask:(uint8_t)optionsMask
    optionsOverride:(uint8_t)optionsOverride
    responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.MoveHue(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionsMask, optionsOverride);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)moveSaturation:(uint8_t)moveMode
                  rate:(uint8_t)rate
           optionsMask:(uint8_t)optionsMask
       optionsOverride:(uint8_t)optionsOverride
       responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.MoveSaturation(
            onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionsMask, optionsOverride);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)moveToColor:(uint16_t)colorX
             colorY:(uint16_t)colorY
     transitionTime:(uint16_t)transitionTime
        optionsMask:(uint8_t)optionsMask
    optionsOverride:(uint8_t)optionsOverride
    responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.MoveToColor(
            onSuccess->Cancel(), onFailure->Cancel(), colorX, colorY, transitionTime, optionsMask, optionsOverride);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)moveToColorTemperature:(uint16_t)colorTemperature
                transitionTime:(uint16_t)transitionTime
                   optionsMask:(uint8_t)optionsMask
               optionsOverride:(uint8_t)optionsOverride
               responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.MoveToColorTemperature(
            onSuccess->Cancel(), onFailure->Cancel(), colorTemperature, transitionTime, optionsMask, optionsOverride);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)moveToHue:(uint8_t)hue
          direction:(uint8_t)direction
     transitionTime:(uint16_t)transitionTime
        optionsMask:(uint8_t)optionsMask
    optionsOverride:(uint8_t)optionsOverride
    responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.MoveToHue(
            onSuccess->Cancel(), onFailure->Cancel(), hue, direction, transitionTime, optionsMask, optionsOverride);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)moveToHueAndSaturation:(uint8_t)hue
                    saturation:(uint8_t)saturation
                transitionTime:(uint16_t)transitionTime
                   optionsMask:(uint8_t)optionsMask
               optionsOverride:(uint8_t)optionsOverride
               responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.MoveToHueAndSaturation(
            onSuccess->Cancel(), onFailure->Cancel(), hue, saturation, transitionTime, optionsMask, optionsOverride);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)moveToSaturation:(uint8_t)saturation
          transitionTime:(uint16_t)transitionTime
             optionsMask:(uint8_t)optionsMask
         optionsOverride:(uint8_t)optionsOverride
         responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.MoveToSaturation(
            onSuccess->Cancel(), onFailure->Cancel(), saturation, transitionTime, optionsMask, optionsOverride);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)stepColor:(int16_t)stepX
              stepY:(int16_t)stepY
     transitionTime:(uint16_t)transitionTime
        optionsMask:(uint8_t)optionsMask
    optionsOverride:(uint8_t)optionsOverride
    responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.StepColor(
            onSuccess->Cancel(), onFailure->Cancel(), stepX, stepY, transitionTime, optionsMask, optionsOverride);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)stepColorTemperature:(uint8_t)stepMode
                    stepSize:(uint16_t)stepSize
              transitionTime:(uint16_t)transitionTime
     colorTemperatureMinimum:(uint16_t)colorTemperatureMinimum
     colorTemperatureMaximum:(uint16_t)colorTemperatureMaximum
                 optionsMask:(uint8_t)optionsMask
             optionsOverride:(uint8_t)optionsOverride
             responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.StepColorTemperature(onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime,
            colorTemperatureMinimum, colorTemperatureMaximum, optionsMask, optionsOverride);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)stepHue:(uint8_t)stepMode
           stepSize:(uint8_t)stepSize
     transitionTime:(uint8_t)transitionTime
        optionsMask:(uint8_t)optionsMask
    optionsOverride:(uint8_t)optionsOverride
    responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.StepHue(
            onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionsMask, optionsOverride);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)stepSaturation:(uint8_t)stepMode
              stepSize:(uint8_t)stepSize
        transitionTime:(uint8_t)transitionTime
           optionsMask:(uint8_t)optionsMask
       optionsOverride:(uint8_t)optionsOverride
       responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.StepSaturation(
            onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionsMask, optionsOverride);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)stopMoveStep:(uint8_t)optionsMask optionsOverride:(uint8_t)optionsOverride responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.StopMoveStep(onSuccess->Cancel(), onFailure->Cancel(), optionsMask, optionsOverride);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeCurrentHueWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeCurrentHue(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)configureAttributeCurrentHueWithMinInterval:(uint16_t)minInterval
                                        maxInterval:(uint16_t)maxInterval
                                             change:(uint8_t)change
                                    responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ConfigureAttributeCurrentHue(
            onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)reportAttributeCurrentHueWithResponseHandler:(ResponseHandler)reportHandler
{
    CHIPInt8uAttributeCallbackBridge * onReport = new CHIPInt8uAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
    if (!onReport) {
        reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReportAttributeCurrentHue(onReport->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onReport;
        reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeCurrentSaturationWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeCurrentSaturation(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)configureAttributeCurrentSaturationWithMinInterval:(uint16_t)minInterval
                                               maxInterval:(uint16_t)maxInterval
                                                    change:(uint8_t)change
                                           responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ConfigureAttributeCurrentSaturation(
            onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)reportAttributeCurrentSaturationWithResponseHandler:(ResponseHandler)reportHandler
{
    CHIPInt8uAttributeCallbackBridge * onReport = new CHIPInt8uAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
    if (!onReport) {
        reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReportAttributeCurrentSaturation(onReport->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onReport;
        reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeRemainingTimeWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeRemainingTime(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeCurrentXWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeCurrentX(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)configureAttributeCurrentXWithMinInterval:(uint16_t)minInterval
                                      maxInterval:(uint16_t)maxInterval
                                           change:(uint16_t)change
                                  responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ConfigureAttributeCurrentX(
            onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)reportAttributeCurrentXWithResponseHandler:(ResponseHandler)reportHandler
{
    CHIPInt16uAttributeCallbackBridge * onReport = new CHIPInt16uAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
    if (!onReport) {
        reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReportAttributeCurrentX(onReport->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onReport;
        reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeCurrentYWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeCurrentY(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)configureAttributeCurrentYWithMinInterval:(uint16_t)minInterval
                                      maxInterval:(uint16_t)maxInterval
                                           change:(uint16_t)change
                                  responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ConfigureAttributeCurrentY(
            onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)reportAttributeCurrentYWithResponseHandler:(ResponseHandler)reportHandler
{
    CHIPInt16uAttributeCallbackBridge * onReport = new CHIPInt16uAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
    if (!onReport) {
        reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReportAttributeCurrentY(onReport->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onReport;
        reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeDriftCompensationWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeDriftCompensation(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeCompensationTextWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], false);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeCompensationText(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeColorTemperatureWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeColorTemperature(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)configureAttributeColorTemperatureWithMinInterval:(uint16_t)minInterval
                                              maxInterval:(uint16_t)maxInterval
                                                   change:(uint16_t)change
                                          responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ConfigureAttributeColorTemperature(
            onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)reportAttributeColorTemperatureWithResponseHandler:(ResponseHandler)reportHandler
{
    CHIPInt16uAttributeCallbackBridge * onReport = new CHIPInt16uAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
    if (!onReport) {
        reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReportAttributeColorTemperature(onReport->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onReport;
        reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeColorModeWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeColorMode(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeColorControlOptionsWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeColorControlOptions(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeColorControlOptionsWithValue:(uint8_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeColorControlOptions(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeNumberOfPrimariesWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeNumberOfPrimaries(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributePrimary1XWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributePrimary1X(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributePrimary1YWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributePrimary1Y(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributePrimary1IntensityWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributePrimary1Intensity(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributePrimary2XWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributePrimary2X(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributePrimary2YWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributePrimary2Y(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributePrimary2IntensityWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributePrimary2Intensity(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributePrimary3XWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributePrimary3X(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributePrimary3YWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributePrimary3Y(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributePrimary3IntensityWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributePrimary3Intensity(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributePrimary4XWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributePrimary4X(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributePrimary4YWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributePrimary4Y(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributePrimary4IntensityWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributePrimary4Intensity(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributePrimary5XWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributePrimary5X(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributePrimary5YWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributePrimary5Y(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributePrimary5IntensityWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributePrimary5Intensity(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributePrimary6XWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributePrimary6X(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributePrimary6YWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributePrimary6Y(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributePrimary6IntensityWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributePrimary6Intensity(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeWhitePointXWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeWhitePointX(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeWhitePointXWithValue:(uint16_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeWhitePointX(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeWhitePointYWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeWhitePointY(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeWhitePointYWithValue:(uint16_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeWhitePointY(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeColorPointRXWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeColorPointRX(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeColorPointRXWithValue:(uint16_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeColorPointRX(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeColorPointRYWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeColorPointRY(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeColorPointRYWithValue:(uint16_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeColorPointRY(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeColorPointRIntensityWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeColorPointRIntensity(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeColorPointRIntensityWithValue:(uint8_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeColorPointRIntensity(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeColorPointGXWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeColorPointGX(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeColorPointGXWithValue:(uint16_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeColorPointGX(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeColorPointGYWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeColorPointGY(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeColorPointGYWithValue:(uint16_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeColorPointGY(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeColorPointGIntensityWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeColorPointGIntensity(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeColorPointGIntensityWithValue:(uint8_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeColorPointGIntensity(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeColorPointBXWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeColorPointBX(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeColorPointBXWithValue:(uint16_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeColorPointBX(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeColorPointBYWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeColorPointBY(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeColorPointBYWithValue:(uint16_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeColorPointBY(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeColorPointBIntensityWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeColorPointBIntensity(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeColorPointBIntensityWithValue:(uint8_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeColorPointBIntensity(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeEnhancedCurrentHueWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeEnhancedCurrentHue(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeEnhancedColorModeWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeEnhancedColorMode(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeColorLoopActiveWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeColorLoopActive(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeColorLoopDirectionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeColorLoopDirection(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeColorLoopTimeWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeColorLoopTime(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeColorCapabilitiesWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeColorCapabilities(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeColorTempPhysicalMinWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeColorTempPhysicalMin(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeColorTempPhysicalMaxWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeColorTempPhysicalMax(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeCoupleColorTempToLevelMinMiredsWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeCoupleColorTempToLevelMinMireds(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeStartUpColorTemperatureMiredsWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeStartUpColorTemperatureMireds(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeStartUpColorTemperatureMiredsWithValue:(uint16_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeStartUpColorTemperatureMireds(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPContentLauncher ()
@property (readonly) Controller::ContentLauncherCluster cppCluster;
@end

@implementation CHIPContentLauncher

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)launchContent:(uint8_t)autoPlay data:(NSString *)data responseHandler:(ResponseHandler)responseHandler
{
    CHIPContentLauncherClusterLaunchContentResponseCallbackBridge * onSuccess
        = new CHIPContentLauncherClusterLaunchContentResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.LaunchContent(onSuccess->Cancel(), onFailure->Cancel(), autoPlay,
            chip::ByteSpan((const uint8_t *) [data dataUsingEncoding:NSUTF8StringEncoding].bytes,
                [data lengthOfBytesUsingEncoding:NSUTF8StringEncoding]));
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)launchURL:(NSString *)contentURL displayString:(NSString *)displayString responseHandler:(ResponseHandler)responseHandler
{
    CHIPContentLauncherClusterLaunchURLResponseCallbackBridge * onSuccess
        = new CHIPContentLauncherClusterLaunchURLResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.LaunchURL(onSuccess->Cancel(), onFailure->Cancel(),
            chip::ByteSpan((const uint8_t *) [contentURL dataUsingEncoding:NSUTF8StringEncoding].bytes,
                [contentURL lengthOfBytesUsingEncoding:NSUTF8StringEncoding]),
            chip::ByteSpan((const uint8_t *) [displayString dataUsingEncoding:NSUTF8StringEncoding].bytes,
                [displayString lengthOfBytesUsingEncoding:NSUTF8StringEncoding]));
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeAcceptsHeaderListWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPContentLauncherAcceptsHeaderListAttributeCallbackBridge * onSuccess
        = new CHIPContentLauncherAcceptsHeaderListAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeAcceptsHeaderList(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeSupportedStreamingTypesWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPContentLauncherSupportedStreamingTypesAttributeCallbackBridge * onSuccess
        = new CHIPContentLauncherSupportedStreamingTypesAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeSupportedStreamingTypes(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPDescriptor ()
@property (readonly) Controller::DescriptorCluster cppCluster;
@end

@implementation CHIPDescriptor

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)readAttributeDeviceListWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPDescriptorDeviceListAttributeCallbackBridge * onSuccess
        = new CHIPDescriptorDeviceListAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeDeviceList(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeServerListWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPDescriptorServerListAttributeCallbackBridge * onSuccess
        = new CHIPDescriptorServerListAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeServerList(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClientListWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPDescriptorClientListAttributeCallbackBridge * onSuccess
        = new CHIPDescriptorClientListAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClientList(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributePartsListWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPDescriptorPartsListAttributeCallbackBridge * onSuccess
        = new CHIPDescriptorPartsListAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributePartsList(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPDiagnosticLogs ()
@property (readonly) Controller::DiagnosticLogsCluster cppCluster;
@end

@implementation CHIPDiagnosticLogs

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)retrieveLogsRequest:(uint8_t)intent
          requestedProtocol:(uint8_t)requestedProtocol
     transferFileDesignator:(NSData *)transferFileDesignator
            responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.RetrieveLogsRequest(onSuccess->Cancel(), onFailure->Cancel(), intent, requestedProtocol,
            chip::ByteSpan((const uint8_t *) transferFileDesignator.bytes, transferFileDesignator.length));
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPDoorLock ()
@property (readonly) Controller::DoorLockCluster cppCluster;
@end

@implementation CHIPDoorLock

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)clearAllPins:(ResponseHandler)responseHandler
{
    CHIPDoorLockClusterClearAllPinsResponseCallbackBridge * onSuccess
        = new CHIPDoorLockClusterClearAllPinsResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ClearAllPins(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)clearAllRfids:(ResponseHandler)responseHandler
{
    CHIPDoorLockClusterClearAllRfidsResponseCallbackBridge * onSuccess
        = new CHIPDoorLockClusterClearAllRfidsResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ClearAllRfids(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)clearHolidaySchedule:(uint8_t)scheduleId responseHandler:(ResponseHandler)responseHandler
{
    CHIPDoorLockClusterClearHolidayScheduleResponseCallbackBridge * onSuccess
        = new CHIPDoorLockClusterClearHolidayScheduleResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ClearHolidaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)clearPin:(uint16_t)userId responseHandler:(ResponseHandler)responseHandler
{
    CHIPDoorLockClusterClearPinResponseCallbackBridge * onSuccess
        = new CHIPDoorLockClusterClearPinResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ClearPin(onSuccess->Cancel(), onFailure->Cancel(), userId);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)clearRfid:(uint16_t)userId responseHandler:(ResponseHandler)responseHandler
{
    CHIPDoorLockClusterClearRfidResponseCallbackBridge * onSuccess
        = new CHIPDoorLockClusterClearRfidResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ClearRfid(onSuccess->Cancel(), onFailure->Cancel(), userId);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)clearWeekdaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId responseHandler:(ResponseHandler)responseHandler
{
    CHIPDoorLockClusterClearWeekdayScheduleResponseCallbackBridge * onSuccess
        = new CHIPDoorLockClusterClearWeekdayScheduleResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ClearWeekdaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)clearYeardaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId responseHandler:(ResponseHandler)responseHandler
{
    CHIPDoorLockClusterClearYeardayScheduleResponseCallbackBridge * onSuccess
        = new CHIPDoorLockClusterClearYeardayScheduleResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ClearYeardaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)getHolidaySchedule:(uint8_t)scheduleId responseHandler:(ResponseHandler)responseHandler
{
    CHIPDoorLockClusterGetHolidayScheduleResponseCallbackBridge * onSuccess
        = new CHIPDoorLockClusterGetHolidayScheduleResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.GetHolidaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)getLogRecord:(uint16_t)logIndex responseHandler:(ResponseHandler)responseHandler
{
    CHIPDoorLockClusterGetLogRecordResponseCallbackBridge * onSuccess
        = new CHIPDoorLockClusterGetLogRecordResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.GetLogRecord(onSuccess->Cancel(), onFailure->Cancel(), logIndex);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)getPin:(uint16_t)userId responseHandler:(ResponseHandler)responseHandler
{
    CHIPDoorLockClusterGetPinResponseCallbackBridge * onSuccess
        = new CHIPDoorLockClusterGetPinResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.GetPin(onSuccess->Cancel(), onFailure->Cancel(), userId);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)getRfid:(uint16_t)userId responseHandler:(ResponseHandler)responseHandler
{
    CHIPDoorLockClusterGetRfidResponseCallbackBridge * onSuccess
        = new CHIPDoorLockClusterGetRfidResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.GetRfid(onSuccess->Cancel(), onFailure->Cancel(), userId);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)getUserType:(uint16_t)userId responseHandler:(ResponseHandler)responseHandler
{
    CHIPDoorLockClusterGetUserTypeResponseCallbackBridge * onSuccess
        = new CHIPDoorLockClusterGetUserTypeResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.GetUserType(onSuccess->Cancel(), onFailure->Cancel(), userId);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)getWeekdaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId responseHandler:(ResponseHandler)responseHandler
{
    CHIPDoorLockClusterGetWeekdayScheduleResponseCallbackBridge * onSuccess
        = new CHIPDoorLockClusterGetWeekdayScheduleResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.GetWeekdaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)getYeardaySchedule:(uint8_t)scheduleId userId:(uint16_t)userId responseHandler:(ResponseHandler)responseHandler
{
    CHIPDoorLockClusterGetYeardayScheduleResponseCallbackBridge * onSuccess
        = new CHIPDoorLockClusterGetYeardayScheduleResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.GetYeardaySchedule(onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)lockDoor:(NSString *)pin responseHandler:(ResponseHandler)responseHandler
{
    CHIPDoorLockClusterLockDoorResponseCallbackBridge * onSuccess
        = new CHIPDoorLockClusterLockDoorResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.LockDoor(onSuccess->Cancel(), onFailure->Cancel(),
            chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes,
                [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding]));
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)setHolidaySchedule:(uint8_t)scheduleId
                localStartTime:(uint32_t)localStartTime
                  localEndTime:(uint32_t)localEndTime
    operatingModeDuringHoliday:(uint8_t)operatingModeDuringHoliday
               responseHandler:(ResponseHandler)responseHandler
{
    CHIPDoorLockClusterSetHolidayScheduleResponseCallbackBridge * onSuccess
        = new CHIPDoorLockClusterSetHolidayScheduleResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.SetHolidaySchedule(
            onSuccess->Cancel(), onFailure->Cancel(), scheduleId, localStartTime, localEndTime, operatingModeDuringHoliday);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)setPin:(uint16_t)userId
         userStatus:(uint8_t)userStatus
           userType:(uint8_t)userType
                pin:(NSString *)pin
    responseHandler:(ResponseHandler)responseHandler
{
    CHIPDoorLockClusterSetPinResponseCallbackBridge * onSuccess
        = new CHIPDoorLockClusterSetPinResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.SetPin(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType,
            chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes,
                [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding]));
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)setRfid:(uint16_t)userId
         userStatus:(uint8_t)userStatus
           userType:(uint8_t)userType
                 id:(NSString *)id
    responseHandler:(ResponseHandler)responseHandler
{
    CHIPDoorLockClusterSetRfidResponseCallbackBridge * onSuccess
        = new CHIPDoorLockClusterSetRfidResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.SetRfid(onSuccess->Cancel(), onFailure->Cancel(), userId, userStatus, userType,
            chip::ByteSpan((const uint8_t *) [id dataUsingEncoding:NSUTF8StringEncoding].bytes,
                [id lengthOfBytesUsingEncoding:NSUTF8StringEncoding]));
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)setUserType:(uint16_t)userId userType:(uint8_t)userType responseHandler:(ResponseHandler)responseHandler
{
    CHIPDoorLockClusterSetUserTypeResponseCallbackBridge * onSuccess
        = new CHIPDoorLockClusterSetUserTypeResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.SetUserType(onSuccess->Cancel(), onFailure->Cancel(), userId, userType);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)setWeekdaySchedule:(uint8_t)scheduleId
                    userId:(uint16_t)userId
                  daysMask:(uint8_t)daysMask
                 startHour:(uint8_t)startHour
               startMinute:(uint8_t)startMinute
                   endHour:(uint8_t)endHour
                 endMinute:(uint8_t)endMinute
           responseHandler:(ResponseHandler)responseHandler
{
    CHIPDoorLockClusterSetWeekdayScheduleResponseCallbackBridge * onSuccess
        = new CHIPDoorLockClusterSetWeekdayScheduleResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.SetWeekdaySchedule(
            onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId, daysMask, startHour, startMinute, endHour, endMinute);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)setYeardaySchedule:(uint8_t)scheduleId
                    userId:(uint16_t)userId
            localStartTime:(uint32_t)localStartTime
              localEndTime:(uint32_t)localEndTime
           responseHandler:(ResponseHandler)responseHandler
{
    CHIPDoorLockClusterSetYeardayScheduleResponseCallbackBridge * onSuccess
        = new CHIPDoorLockClusterSetYeardayScheduleResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.SetYeardaySchedule(
            onSuccess->Cancel(), onFailure->Cancel(), scheduleId, userId, localStartTime, localEndTime);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)unlockDoor:(NSString *)pin responseHandler:(ResponseHandler)responseHandler
{
    CHIPDoorLockClusterUnlockDoorResponseCallbackBridge * onSuccess
        = new CHIPDoorLockClusterUnlockDoorResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.UnlockDoor(onSuccess->Cancel(), onFailure->Cancel(),
            chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes,
                [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding]));
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)unlockWithTimeout:(uint16_t)timeoutInSeconds pin:(NSString *)pin responseHandler:(ResponseHandler)responseHandler
{
    CHIPDoorLockClusterUnlockWithTimeoutResponseCallbackBridge * onSuccess
        = new CHIPDoorLockClusterUnlockWithTimeoutResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.UnlockWithTimeout(onSuccess->Cancel(), onFailure->Cancel(), timeoutInSeconds,
            chip::ByteSpan((const uint8_t *) [pin dataUsingEncoding:NSUTF8StringEncoding].bytes,
                [pin lengthOfBytesUsingEncoding:NSUTF8StringEncoding]));
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeLockStateWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeLockState(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)configureAttributeLockStateWithMinInterval:(uint16_t)minInterval
                                       maxInterval:(uint16_t)maxInterval
                                   responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ConfigureAttributeLockState(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)reportAttributeLockStateWithResponseHandler:(ResponseHandler)reportHandler
{
    CHIPInt8uAttributeCallbackBridge * onReport = new CHIPInt8uAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
    if (!onReport) {
        reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReportAttributeLockState(onReport->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onReport;
        reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeLockTypeWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeLockType(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeActuatorEnabledWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPBooleanAttributeCallbackBridge * onSuccess = new CHIPBooleanAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeActuatorEnabled(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPElectricalMeasurement ()
@property (readonly) Controller::ElectricalMeasurementCluster cppCluster;
@end

@implementation CHIPElectricalMeasurement

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)readAttributeMeasurementTypeWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeMeasurementType(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeTotalActivePowerWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32sAttributeCallbackBridge * onSuccess = new CHIPInt32sAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeTotalActivePower(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeRmsVoltageWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeRmsVoltage(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeRmsVoltageMinWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeRmsVoltageMin(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeRmsVoltageMaxWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeRmsVoltageMax(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeRmsCurrentWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeRmsCurrent(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeRmsCurrentMinWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeRmsCurrentMin(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeRmsCurrentMaxWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeRmsCurrentMax(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeActivePowerWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16sAttributeCallbackBridge * onSuccess = new CHIPInt16sAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeActivePower(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeActivePowerMinWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16sAttributeCallbackBridge * onSuccess = new CHIPInt16sAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeActivePowerMin(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeActivePowerMaxWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16sAttributeCallbackBridge * onSuccess = new CHIPInt16sAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeActivePowerMax(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPEthernetNetworkDiagnostics ()
@property (readonly) Controller::EthernetNetworkDiagnosticsCluster cppCluster;
@end

@implementation CHIPEthernetNetworkDiagnostics

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)resetCounts:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ResetCounts(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributePacketRxCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt64uAttributeCallbackBridge * onSuccess = new CHIPInt64uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributePacketRxCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributePacketTxCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt64uAttributeCallbackBridge * onSuccess = new CHIPInt64uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributePacketTxCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeTxErrCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt64uAttributeCallbackBridge * onSuccess = new CHIPInt64uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeTxErrCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeCollisionCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt64uAttributeCallbackBridge * onSuccess = new CHIPInt64uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeCollisionCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeOverrunCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt64uAttributeCallbackBridge * onSuccess = new CHIPInt64uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeOverrunCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPFixedLabel ()
@property (readonly) Controller::FixedLabelCluster cppCluster;
@end

@implementation CHIPFixedLabel

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)readAttributeLabelListWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPFixedLabelLabelListAttributeCallbackBridge * onSuccess
        = new CHIPFixedLabelLabelListAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeLabelList(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPFlowMeasurement ()
@property (readonly) Controller::FlowMeasurementCluster cppCluster;
@end

@implementation CHIPFlowMeasurement

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)readAttributeMeasuredValueWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16sAttributeCallbackBridge * onSuccess = new CHIPInt16sAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeMeasuredValue(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeMinMeasuredValueWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16sAttributeCallbackBridge * onSuccess = new CHIPInt16sAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeMinMeasuredValue(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeMaxMeasuredValueWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16sAttributeCallbackBridge * onSuccess = new CHIPInt16sAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeMaxMeasuredValue(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPGeneralCommissioning ()
@property (readonly) Controller::GeneralCommissioningCluster cppCluster;
@end

@implementation CHIPGeneralCommissioning

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)armFailSafe:(uint16_t)expiryLengthSeconds
         breadcrumb:(uint64_t)breadcrumb
          timeoutMs:(uint32_t)timeoutMs
    responseHandler:(ResponseHandler)responseHandler
{
    CHIPGeneralCommissioningClusterArmFailSafeResponseCallbackBridge * onSuccess
        = new CHIPGeneralCommissioningClusterArmFailSafeResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ArmFailSafe(onSuccess->Cancel(), onFailure->Cancel(), expiryLengthSeconds, breadcrumb, timeoutMs);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)commissioningComplete:(ResponseHandler)responseHandler
{
    CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallbackBridge * onSuccess
        = new CHIPGeneralCommissioningClusterCommissioningCompleteResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.CommissioningComplete(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)setRegulatoryConfig:(uint8_t)location
                countryCode:(NSString *)countryCode
                 breadcrumb:(uint64_t)breadcrumb
                  timeoutMs:(uint32_t)timeoutMs
            responseHandler:(ResponseHandler)responseHandler
{
    CHIPGeneralCommissioningClusterSetRegulatoryConfigResponseCallbackBridge * onSuccess
        = new CHIPGeneralCommissioningClusterSetRegulatoryConfigResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.SetRegulatoryConfig(onSuccess->Cancel(), onFailure->Cancel(), location,
            chip::ByteSpan((const uint8_t *) [countryCode dataUsingEncoding:NSUTF8StringEncoding].bytes,
                [countryCode lengthOfBytesUsingEncoding:NSUTF8StringEncoding]),
            breadcrumb, timeoutMs);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeFabricIdWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], true);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeFabricId(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeBreadcrumbWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt64uAttributeCallbackBridge * onSuccess = new CHIPInt64uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeBreadcrumb(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeBreadcrumbWithValue:(uint64_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeBreadcrumb(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPGeneralDiagnostics ()
@property (readonly) Controller::GeneralDiagnosticsCluster cppCluster;
@end

@implementation CHIPGeneralDiagnostics

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)readAttributeNetworkInterfacesWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPGeneralDiagnosticsNetworkInterfacesAttributeCallbackBridge * onSuccess
        = new CHIPGeneralDiagnosticsNetworkInterfacesAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeNetworkInterfaces(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeRebootCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeRebootCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPGroupKeyManagement ()
@property (readonly) Controller::GroupKeyManagementCluster cppCluster;
@end

@implementation CHIPGroupKeyManagement

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)readAttributeGroupsWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPGroupKeyManagementGroupsAttributeCallbackBridge * onSuccess
        = new CHIPGroupKeyManagementGroupsAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeGroups(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeGroupKeysWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPGroupKeyManagementGroupKeysAttributeCallbackBridge * onSuccess
        = new CHIPGroupKeyManagementGroupKeysAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeGroupKeys(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPGroups ()
@property (readonly) Controller::GroupsCluster cppCluster;
@end

@implementation CHIPGroups

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)addGroup:(uint16_t)groupId groupName:(NSString *)groupName responseHandler:(ResponseHandler)responseHandler
{
    CHIPGroupsClusterAddGroupResponseCallbackBridge * onSuccess
        = new CHIPGroupsClusterAddGroupResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.AddGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId,
            chip::ByteSpan((const uint8_t *) [groupName dataUsingEncoding:NSUTF8StringEncoding].bytes,
                [groupName lengthOfBytesUsingEncoding:NSUTF8StringEncoding]));
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)addGroupIfIdentifying:(uint16_t)groupId groupName:(NSString *)groupName responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.AddGroupIfIdentifying(onSuccess->Cancel(), onFailure->Cancel(), groupId,
            chip::ByteSpan((const uint8_t *) [groupName dataUsingEncoding:NSUTF8StringEncoding].bytes,
                [groupName lengthOfBytesUsingEncoding:NSUTF8StringEncoding]));
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)getGroupMembership:(uint8_t)groupCount groupList:(uint16_t)groupList responseHandler:(ResponseHandler)responseHandler
{
    CHIPGroupsClusterGetGroupMembershipResponseCallbackBridge * onSuccess
        = new CHIPGroupsClusterGetGroupMembershipResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.GetGroupMembership(onSuccess->Cancel(), onFailure->Cancel(), groupCount, groupList);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)removeAllGroups:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.RemoveAllGroups(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)removeGroup:(uint16_t)groupId responseHandler:(ResponseHandler)responseHandler
{
    CHIPGroupsClusterRemoveGroupResponseCallbackBridge * onSuccess
        = new CHIPGroupsClusterRemoveGroupResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.RemoveGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)viewGroup:(uint16_t)groupId responseHandler:(ResponseHandler)responseHandler
{
    CHIPGroupsClusterViewGroupResponseCallbackBridge * onSuccess
        = new CHIPGroupsClusterViewGroupResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ViewGroup(onSuccess->Cancel(), onFailure->Cancel(), groupId);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeNameSupportWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeNameSupport(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPIdentify ()
@property (readonly) Controller::IdentifyCluster cppCluster;
@end

@implementation CHIPIdentify

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)identify:(uint16_t)identifyTime responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.Identify(onSuccess->Cancel(), onFailure->Cancel(), identifyTime);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)identifyQuery:(ResponseHandler)responseHandler
{
    CHIPIdentifyClusterIdentifyQueryResponseCallbackBridge * onSuccess
        = new CHIPIdentifyClusterIdentifyQueryResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.IdentifyQuery(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeIdentifyTimeWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeIdentifyTime(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeIdentifyTimeWithValue:(uint16_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeIdentifyTime(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPKeypadInput ()
@property (readonly) Controller::KeypadInputCluster cppCluster;
@end

@implementation CHIPKeypadInput

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)sendKey:(uint8_t)keyCode responseHandler:(ResponseHandler)responseHandler
{
    CHIPKeypadInputClusterSendKeyResponseCallbackBridge * onSuccess
        = new CHIPKeypadInputClusterSendKeyResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.SendKey(onSuccess->Cancel(), onFailure->Cancel(), keyCode);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPLevelControl ()
@property (readonly) Controller::LevelControlCluster cppCluster;
@end

@implementation CHIPLevelControl

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)move:(uint8_t)moveMode
               rate:(uint8_t)rate
         optionMask:(uint8_t)optionMask
     optionOverride:(uint8_t)optionOverride
    responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.Move(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate, optionMask, optionOverride);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)moveToLevel:(uint8_t)level
     transitionTime:(uint16_t)transitionTime
         optionMask:(uint8_t)optionMask
     optionOverride:(uint8_t)optionOverride
    responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.MoveToLevel(
            onSuccess->Cancel(), onFailure->Cancel(), level, transitionTime, optionMask, optionOverride);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)moveToLevelWithOnOff:(uint8_t)level transitionTime:(uint16_t)transitionTime responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.MoveToLevelWithOnOff(onSuccess->Cancel(), onFailure->Cancel(), level, transitionTime);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)moveWithOnOff:(uint8_t)moveMode rate:(uint8_t)rate responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.MoveWithOnOff(onSuccess->Cancel(), onFailure->Cancel(), moveMode, rate);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)step:(uint8_t)stepMode
           stepSize:(uint8_t)stepSize
     transitionTime:(uint16_t)transitionTime
         optionMask:(uint8_t)optionMask
     optionOverride:(uint8_t)optionOverride
    responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.Step(
            onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime, optionMask, optionOverride);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)stepWithOnOff:(uint8_t)stepMode
             stepSize:(uint8_t)stepSize
       transitionTime:(uint16_t)transitionTime
      responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.StepWithOnOff(onSuccess->Cancel(), onFailure->Cancel(), stepMode, stepSize, transitionTime);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)stop:(uint8_t)optionMask optionOverride:(uint8_t)optionOverride responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.Stop(onSuccess->Cancel(), onFailure->Cancel(), optionMask, optionOverride);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)stopWithOnOff:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.StopWithOnOff(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeCurrentLevelWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeCurrentLevel(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)configureAttributeCurrentLevelWithMinInterval:(uint16_t)minInterval
                                          maxInterval:(uint16_t)maxInterval
                                               change:(uint8_t)change
                                      responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ConfigureAttributeCurrentLevel(
            onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)reportAttributeCurrentLevelWithResponseHandler:(ResponseHandler)reportHandler
{
    CHIPInt8uAttributeCallbackBridge * onReport = new CHIPInt8uAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
    if (!onReport) {
        reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReportAttributeCurrentLevel(onReport->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onReport;
        reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPLowPower ()
@property (readonly) Controller::LowPowerCluster cppCluster;
@end

@implementation CHIPLowPower

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)sleep:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.Sleep(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPMediaInput ()
@property (readonly) Controller::MediaInputCluster cppCluster;
@end

@implementation CHIPMediaInput

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)hideInputStatus:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.HideInputStatus(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)renameInput:(uint8_t)index name:(NSString *)name responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.RenameInput(onSuccess->Cancel(), onFailure->Cancel(), index,
            chip::ByteSpan((const uint8_t *) [name dataUsingEncoding:NSUTF8StringEncoding].bytes,
                [name lengthOfBytesUsingEncoding:NSUTF8StringEncoding]));
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)selectInput:(uint8_t)index responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.SelectInput(onSuccess->Cancel(), onFailure->Cancel(), index);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)showInputStatus:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ShowInputStatus(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeMediaInputListWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPMediaInputMediaInputListAttributeCallbackBridge * onSuccess
        = new CHIPMediaInputMediaInputListAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeMediaInputList(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeCurrentMediaInputWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeCurrentMediaInput(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPMediaPlayback ()
@property (readonly) Controller::MediaPlaybackCluster cppCluster;
@end

@implementation CHIPMediaPlayback

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)mediaFastForward:(ResponseHandler)responseHandler
{
    CHIPMediaPlaybackClusterMediaFastForwardResponseCallbackBridge * onSuccess
        = new CHIPMediaPlaybackClusterMediaFastForwardResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.MediaFastForward(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)mediaNext:(ResponseHandler)responseHandler
{
    CHIPMediaPlaybackClusterMediaNextResponseCallbackBridge * onSuccess
        = new CHIPMediaPlaybackClusterMediaNextResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.MediaNext(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)mediaPause:(ResponseHandler)responseHandler
{
    CHIPMediaPlaybackClusterMediaPauseResponseCallbackBridge * onSuccess
        = new CHIPMediaPlaybackClusterMediaPauseResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.MediaPause(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)mediaPlay:(ResponseHandler)responseHandler
{
    CHIPMediaPlaybackClusterMediaPlayResponseCallbackBridge * onSuccess
        = new CHIPMediaPlaybackClusterMediaPlayResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.MediaPlay(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)mediaPrevious:(ResponseHandler)responseHandler
{
    CHIPMediaPlaybackClusterMediaPreviousResponseCallbackBridge * onSuccess
        = new CHIPMediaPlaybackClusterMediaPreviousResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.MediaPrevious(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)mediaRewind:(ResponseHandler)responseHandler
{
    CHIPMediaPlaybackClusterMediaRewindResponseCallbackBridge * onSuccess
        = new CHIPMediaPlaybackClusterMediaRewindResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.MediaRewind(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)mediaSeek:(uint64_t)position responseHandler:(ResponseHandler)responseHandler
{
    CHIPMediaPlaybackClusterMediaSeekResponseCallbackBridge * onSuccess
        = new CHIPMediaPlaybackClusterMediaSeekResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.MediaSeek(onSuccess->Cancel(), onFailure->Cancel(), position);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)mediaSkipBackward:(uint64_t)deltaPositionMilliseconds responseHandler:(ResponseHandler)responseHandler
{
    CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallbackBridge * onSuccess
        = new CHIPMediaPlaybackClusterMediaSkipBackwardResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.MediaSkipBackward(onSuccess->Cancel(), onFailure->Cancel(), deltaPositionMilliseconds);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)mediaSkipForward:(uint64_t)deltaPositionMilliseconds responseHandler:(ResponseHandler)responseHandler
{
    CHIPMediaPlaybackClusterMediaSkipForwardResponseCallbackBridge * onSuccess
        = new CHIPMediaPlaybackClusterMediaSkipForwardResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.MediaSkipForward(onSuccess->Cancel(), onFailure->Cancel(), deltaPositionMilliseconds);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)mediaStartOver:(ResponseHandler)responseHandler
{
    CHIPMediaPlaybackClusterMediaStartOverResponseCallbackBridge * onSuccess
        = new CHIPMediaPlaybackClusterMediaStartOverResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.MediaStartOver(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)mediaStop:(ResponseHandler)responseHandler
{
    CHIPMediaPlaybackClusterMediaStopResponseCallbackBridge * onSuccess
        = new CHIPMediaPlaybackClusterMediaStopResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.MediaStop(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPNetworkCommissioning ()
@property (readonly) Controller::NetworkCommissioningCluster cppCluster;
@end

@implementation CHIPNetworkCommissioning

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)addThreadNetwork:(NSData *)operationalDataset
              breadcrumb:(uint64_t)breadcrumb
               timeoutMs:(uint32_t)timeoutMs
         responseHandler:(ResponseHandler)responseHandler
{
    CHIPNetworkCommissioningClusterAddThreadNetworkResponseCallbackBridge * onSuccess
        = new CHIPNetworkCommissioningClusterAddThreadNetworkResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.AddThreadNetwork(onSuccess->Cancel(), onFailure->Cancel(),
            chip::ByteSpan((const uint8_t *) operationalDataset.bytes, operationalDataset.length), breadcrumb, timeoutMs);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)addWiFiNetwork:(NSData *)ssid
           credentials:(NSData *)credentials
            breadcrumb:(uint64_t)breadcrumb
             timeoutMs:(uint32_t)timeoutMs
       responseHandler:(ResponseHandler)responseHandler
{
    CHIPNetworkCommissioningClusterAddWiFiNetworkResponseCallbackBridge * onSuccess
        = new CHIPNetworkCommissioningClusterAddWiFiNetworkResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.AddWiFiNetwork(onSuccess->Cancel(), onFailure->Cancel(),
            chip::ByteSpan((const uint8_t *) ssid.bytes, ssid.length),
            chip::ByteSpan((const uint8_t *) credentials.bytes, credentials.length), breadcrumb, timeoutMs);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)disableNetwork:(NSData *)networkID
            breadcrumb:(uint64_t)breadcrumb
             timeoutMs:(uint32_t)timeoutMs
       responseHandler:(ResponseHandler)responseHandler
{
    CHIPNetworkCommissioningClusterDisableNetworkResponseCallbackBridge * onSuccess
        = new CHIPNetworkCommissioningClusterDisableNetworkResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.DisableNetwork(onSuccess->Cancel(), onFailure->Cancel(),
            chip::ByteSpan((const uint8_t *) networkID.bytes, networkID.length), breadcrumb, timeoutMs);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)enableNetwork:(NSData *)networkID
           breadcrumb:(uint64_t)breadcrumb
            timeoutMs:(uint32_t)timeoutMs
      responseHandler:(ResponseHandler)responseHandler
{
    CHIPNetworkCommissioningClusterEnableNetworkResponseCallbackBridge * onSuccess
        = new CHIPNetworkCommissioningClusterEnableNetworkResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.EnableNetwork(onSuccess->Cancel(), onFailure->Cancel(),
            chip::ByteSpan((const uint8_t *) networkID.bytes, networkID.length), breadcrumb, timeoutMs);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)getLastNetworkCommissioningResult:(uint32_t)timeoutMs responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.GetLastNetworkCommissioningResult(onSuccess->Cancel(), onFailure->Cancel(), timeoutMs);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)removeNetwork:(NSData *)networkID
           breadcrumb:(uint64_t)breadcrumb
            timeoutMs:(uint32_t)timeoutMs
      responseHandler:(ResponseHandler)responseHandler
{
    CHIPNetworkCommissioningClusterRemoveNetworkResponseCallbackBridge * onSuccess
        = new CHIPNetworkCommissioningClusterRemoveNetworkResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.RemoveNetwork(onSuccess->Cancel(), onFailure->Cancel(),
            chip::ByteSpan((const uint8_t *) networkID.bytes, networkID.length), breadcrumb, timeoutMs);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)scanNetworks:(NSData *)ssid
          breadcrumb:(uint64_t)breadcrumb
           timeoutMs:(uint32_t)timeoutMs
     responseHandler:(ResponseHandler)responseHandler
{
    CHIPNetworkCommissioningClusterScanNetworksResponseCallbackBridge * onSuccess
        = new CHIPNetworkCommissioningClusterScanNetworksResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ScanNetworks(onSuccess->Cancel(), onFailure->Cancel(),
            chip::ByteSpan((const uint8_t *) ssid.bytes, ssid.length), breadcrumb, timeoutMs);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)updateThreadNetwork:(NSData *)operationalDataset
                 breadcrumb:(uint64_t)breadcrumb
                  timeoutMs:(uint32_t)timeoutMs
            responseHandler:(ResponseHandler)responseHandler
{
    CHIPNetworkCommissioningClusterUpdateThreadNetworkResponseCallbackBridge * onSuccess
        = new CHIPNetworkCommissioningClusterUpdateThreadNetworkResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.UpdateThreadNetwork(onSuccess->Cancel(), onFailure->Cancel(),
            chip::ByteSpan((const uint8_t *) operationalDataset.bytes, operationalDataset.length), breadcrumb, timeoutMs);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)updateWiFiNetwork:(NSData *)ssid
              credentials:(NSData *)credentials
               breadcrumb:(uint64_t)breadcrumb
                timeoutMs:(uint32_t)timeoutMs
          responseHandler:(ResponseHandler)responseHandler
{
    CHIPNetworkCommissioningClusterUpdateWiFiNetworkResponseCallbackBridge * onSuccess
        = new CHIPNetworkCommissioningClusterUpdateWiFiNetworkResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.UpdateWiFiNetwork(onSuccess->Cancel(), onFailure->Cancel(),
            chip::ByteSpan((const uint8_t *) ssid.bytes, ssid.length),
            chip::ByteSpan((const uint8_t *) credentials.bytes, credentials.length), breadcrumb, timeoutMs);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPOtaSoftwareUpdateProvider ()
@property (readonly) Controller::OtaSoftwareUpdateProviderCluster cppCluster;
@end

@implementation CHIPOtaSoftwareUpdateProvider

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)applyUpdateRequest:(NSData *)updateToken newVersion:(uint32_t)newVersion responseHandler:(ResponseHandler)responseHandler
{
    CHIPOtaSoftwareUpdateProviderClusterApplyUpdateRequestResponseCallbackBridge * onSuccess
        = new CHIPOtaSoftwareUpdateProviderClusterApplyUpdateRequestResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ApplyUpdateRequest(onSuccess->Cancel(), onFailure->Cancel(),
            chip::ByteSpan((const uint8_t *) updateToken.bytes, updateToken.length), newVersion);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)notifyUpdateApplied:(NSData *)updateToken
             currentVersion:(uint32_t)currentVersion
            responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.NotifyUpdateApplied(onSuccess->Cancel(), onFailure->Cancel(),
            chip::ByteSpan((const uint8_t *) updateToken.bytes, updateToken.length), currentVersion);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)queryImage:(uint16_t)vendorId
              productId:(uint16_t)productId
              imageType:(uint16_t)imageType
        hardwareVersion:(uint16_t)hardwareVersion
         currentVersion:(uint32_t)currentVersion
     protocolsSupported:(uint8_t)protocolsSupported
               location:(NSString *)location
    requestorCanConsent:(uint8_t)requestorCanConsent
    metadataForProvider:(NSData *)metadataForProvider
        responseHandler:(ResponseHandler)responseHandler
{
    CHIPOtaSoftwareUpdateProviderClusterQueryImageResponseCallbackBridge * onSuccess
        = new CHIPOtaSoftwareUpdateProviderClusterQueryImageResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.QueryImage(onSuccess->Cancel(), onFailure->Cancel(), vendorId, productId, imageType, hardwareVersion,
            currentVersion, protocolsSupported,
            chip::ByteSpan((const uint8_t *) [location dataUsingEncoding:NSUTF8StringEncoding].bytes,
                [location lengthOfBytesUsingEncoding:NSUTF8StringEncoding]),
            requestorCanConsent, chip::ByteSpan((const uint8_t *) metadataForProvider.bytes, metadataForProvider.length));
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPOccupancySensing ()
@property (readonly) Controller::OccupancySensingCluster cppCluster;
@end

@implementation CHIPOccupancySensing

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)readAttributeOccupancyWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeOccupancy(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)configureAttributeOccupancyWithMinInterval:(uint16_t)minInterval
                                       maxInterval:(uint16_t)maxInterval
                                   responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ConfigureAttributeOccupancy(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)reportAttributeOccupancyWithResponseHandler:(ResponseHandler)reportHandler
{
    CHIPInt8uAttributeCallbackBridge * onReport = new CHIPInt8uAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
    if (!onReport) {
        reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReportAttributeOccupancy(onReport->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onReport;
        reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeOccupancySensorTypeWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeOccupancySensorType(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeOccupancySensorTypeBitmapWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeOccupancySensorTypeBitmap(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPOnOff ()
@property (readonly) Controller::OnOffCluster cppCluster;
@end

@implementation CHIPOnOff

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)off:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.Off(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)offWithEffect:(uint8_t)effectId effectVariant:(uint8_t)effectVariant responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.OffWithEffect(onSuccess->Cancel(), onFailure->Cancel(), effectId, effectVariant);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)on:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.On(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)onWithRecallGlobalScene:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.OnWithRecallGlobalScene(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)onWithTimedOff:(uint8_t)onOffControl
                onTime:(uint16_t)onTime
           offWaitTime:(uint16_t)offWaitTime
       responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.OnWithTimedOff(onSuccess->Cancel(), onFailure->Cancel(), onOffControl, onTime, offWaitTime);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)toggle:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.Toggle(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeOnOffWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPBooleanAttributeCallbackBridge * onSuccess = new CHIPBooleanAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeOnOff(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)configureAttributeOnOffWithMinInterval:(uint16_t)minInterval
                                   maxInterval:(uint16_t)maxInterval
                               responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ConfigureAttributeOnOff(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)reportAttributeOnOffWithResponseHandler:(ResponseHandler)reportHandler
{
    CHIPBooleanAttributeCallbackBridge * onReport
        = new CHIPBooleanAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
    if (!onReport) {
        reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReportAttributeOnOff(onReport->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onReport;
        reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeGlobalSceneControlWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPBooleanAttributeCallbackBridge * onSuccess = new CHIPBooleanAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeGlobalSceneControl(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeOnTimeWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeOnTime(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeOnTimeWithValue:(uint16_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeOnTime(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeOffWaitTimeWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeOffWaitTime(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeOffWaitTimeWithValue:(uint16_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeOffWaitTime(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeStartUpOnOffWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeStartUpOnOff(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeStartUpOnOffWithValue:(uint8_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeStartUpOnOff(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeFeatureMapWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeFeatureMap(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPOperationalCredentials ()
@property (readonly) Controller::OperationalCredentialsCluster cppCluster;
@end

@implementation CHIPOperationalCredentials

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)addOpCert:(NSData *)nOCArray
           iPKValue:(NSData *)iPKValue
      caseAdminNode:(uint64_t)caseAdminNode
      adminVendorId:(uint16_t)adminVendorId
    responseHandler:(ResponseHandler)responseHandler
{
    CHIPOperationalCredentialsClusterOpCertResponseCallbackBridge * onSuccess
        = new CHIPOperationalCredentialsClusterOpCertResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.AddOpCert(onSuccess->Cancel(), onFailure->Cancel(),
            chip::ByteSpan((const uint8_t *) nOCArray.bytes, nOCArray.length),
            chip::ByteSpan((const uint8_t *) iPKValue.bytes, iPKValue.length), caseAdminNode, adminVendorId);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)addTrustedRootCertificate:(NSData *)rootCertificate responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.AddTrustedRootCertificate(onSuccess->Cancel(), onFailure->Cancel(),
            chip::ByteSpan((const uint8_t *) rootCertificate.bytes, rootCertificate.length));
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)opCSRRequest:(NSData *)cSRNonce responseHandler:(ResponseHandler)responseHandler
{
    CHIPOperationalCredentialsClusterOpCSRResponseCallbackBridge * onSuccess
        = new CHIPOperationalCredentialsClusterOpCSRResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.OpCSRRequest(
            onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) cSRNonce.bytes, cSRNonce.length));
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)removeAllFabrics:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.RemoveAllFabrics(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)removeFabric:(uint64_t)fabricId
              nodeId:(uint64_t)nodeId
            vendorId:(uint16_t)vendorId
     responseHandler:(ResponseHandler)responseHandler
{
    CHIPOperationalCredentialsClusterOpCertResponseCallbackBridge * onSuccess
        = new CHIPOperationalCredentialsClusterOpCertResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.RemoveFabric(onSuccess->Cancel(), onFailure->Cancel(), fabricId, nodeId, vendorId);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)removeTrustedRootCertificate:(NSData *)trustedRootIdentifier responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.RemoveTrustedRootCertificate(onSuccess->Cancel(), onFailure->Cancel(),
            chip::ByteSpan((const uint8_t *) trustedRootIdentifier.bytes, trustedRootIdentifier.length));
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)setFabric:(uint16_t)vendorId responseHandler:(ResponseHandler)responseHandler
{
    CHIPOperationalCredentialsClusterSetFabricResponseCallbackBridge * onSuccess
        = new CHIPOperationalCredentialsClusterSetFabricResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.SetFabric(onSuccess->Cancel(), onFailure->Cancel(), vendorId);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)updateFabricLabel:(NSString *)label responseHandler:(ResponseHandler)responseHandler
{
    CHIPOperationalCredentialsClusterOpCertResponseCallbackBridge * onSuccess
        = new CHIPOperationalCredentialsClusterOpCertResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.UpdateFabricLabel(onSuccess->Cancel(), onFailure->Cancel(),
            chip::ByteSpan((const uint8_t *) [label dataUsingEncoding:NSUTF8StringEncoding].bytes,
                [label lengthOfBytesUsingEncoding:NSUTF8StringEncoding]));
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeFabricsListWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPOperationalCredentialsFabricsListAttributeCallbackBridge * onSuccess
        = new CHIPOperationalCredentialsFabricsListAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeFabricsList(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPPressureMeasurement ()
@property (readonly) Controller::PressureMeasurementCluster cppCluster;
@end

@implementation CHIPPressureMeasurement

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)readAttributeMeasuredValueWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16sAttributeCallbackBridge * onSuccess = new CHIPInt16sAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeMeasuredValue(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)configureAttributeMeasuredValueWithMinInterval:(uint16_t)minInterval
                                           maxInterval:(uint16_t)maxInterval
                                                change:(int16_t)change
                                       responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ConfigureAttributeMeasuredValue(
            onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)reportAttributeMeasuredValueWithResponseHandler:(ResponseHandler)reportHandler
{
    CHIPInt16sAttributeCallbackBridge * onReport = new CHIPInt16sAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
    if (!onReport) {
        reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReportAttributeMeasuredValue(onReport->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onReport;
        reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeMinMeasuredValueWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16sAttributeCallbackBridge * onSuccess = new CHIPInt16sAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeMinMeasuredValue(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeMaxMeasuredValueWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16sAttributeCallbackBridge * onSuccess = new CHIPInt16sAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeMaxMeasuredValue(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPPumpConfigurationAndControl ()
@property (readonly) Controller::PumpConfigurationAndControlCluster cppCluster;
@end

@implementation CHIPPumpConfigurationAndControl

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)readAttributeMaxPressureWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16sAttributeCallbackBridge * onSuccess = new CHIPInt16sAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeMaxPressure(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeMaxSpeedWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeMaxSpeed(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeMaxFlowWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeMaxFlow(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeEffectiveOperationModeWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeEffectiveOperationMode(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeEffectiveControlModeWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeEffectiveControlMode(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeCapacityWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16sAttributeCallbackBridge * onSuccess = new CHIPInt16sAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeCapacity(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)configureAttributeCapacityWithMinInterval:(uint16_t)minInterval
                                      maxInterval:(uint16_t)maxInterval
                                           change:(int16_t)change
                                  responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ConfigureAttributeCapacity(
            onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)reportAttributeCapacityWithResponseHandler:(ResponseHandler)reportHandler
{
    CHIPInt16sAttributeCallbackBridge * onReport = new CHIPInt16sAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
    if (!onReport) {
        reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReportAttributeCapacity(onReport->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onReport;
        reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeOperationModeWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeOperationMode(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeOperationModeWithValue:(uint8_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeOperationMode(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPRelativeHumidityMeasurement ()
@property (readonly) Controller::RelativeHumidityMeasurementCluster cppCluster;
@end

@implementation CHIPRelativeHumidityMeasurement

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)readAttributeMeasuredValueWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeMeasuredValue(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)configureAttributeMeasuredValueWithMinInterval:(uint16_t)minInterval
                                           maxInterval:(uint16_t)maxInterval
                                                change:(uint16_t)change
                                       responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ConfigureAttributeMeasuredValue(
            onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)reportAttributeMeasuredValueWithResponseHandler:(ResponseHandler)reportHandler
{
    CHIPInt16uAttributeCallbackBridge * onReport = new CHIPInt16uAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
    if (!onReport) {
        reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReportAttributeMeasuredValue(onReport->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onReport;
        reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeMinMeasuredValueWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeMinMeasuredValue(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeMaxMeasuredValueWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeMaxMeasuredValue(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPScenes ()
@property (readonly) Controller::ScenesCluster cppCluster;
@end

@implementation CHIPScenes

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)addScene:(uint16_t)groupId
            sceneId:(uint8_t)sceneId
     transitionTime:(uint16_t)transitionTime
          sceneName:(NSString *)sceneName
          clusterId:(uint32_t)clusterId
             length:(uint8_t)length
              value:(uint8_t)value
    responseHandler:(ResponseHandler)responseHandler
{
    CHIPScenesClusterAddSceneResponseCallbackBridge * onSuccess
        = new CHIPScenesClusterAddSceneResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.AddScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId, transitionTime,
            chip::ByteSpan((const uint8_t *) [sceneName dataUsingEncoding:NSUTF8StringEncoding].bytes,
                [sceneName lengthOfBytesUsingEncoding:NSUTF8StringEncoding]),
            clusterId, length, value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)getSceneMembership:(uint16_t)groupId responseHandler:(ResponseHandler)responseHandler
{
    CHIPScenesClusterGetSceneMembershipResponseCallbackBridge * onSuccess
        = new CHIPScenesClusterGetSceneMembershipResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.GetSceneMembership(onSuccess->Cancel(), onFailure->Cancel(), groupId);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)recallScene:(uint16_t)groupId
            sceneId:(uint8_t)sceneId
     transitionTime:(uint16_t)transitionTime
    responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.RecallScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId, transitionTime);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)removeAllScenes:(uint16_t)groupId responseHandler:(ResponseHandler)responseHandler
{
    CHIPScenesClusterRemoveAllScenesResponseCallbackBridge * onSuccess
        = new CHIPScenesClusterRemoveAllScenesResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.RemoveAllScenes(onSuccess->Cancel(), onFailure->Cancel(), groupId);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)removeScene:(uint16_t)groupId sceneId:(uint8_t)sceneId responseHandler:(ResponseHandler)responseHandler
{
    CHIPScenesClusterRemoveSceneResponseCallbackBridge * onSuccess
        = new CHIPScenesClusterRemoveSceneResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.RemoveScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)storeScene:(uint16_t)groupId sceneId:(uint8_t)sceneId responseHandler:(ResponseHandler)responseHandler
{
    CHIPScenesClusterStoreSceneResponseCallbackBridge * onSuccess
        = new CHIPScenesClusterStoreSceneResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.StoreScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)viewScene:(uint16_t)groupId sceneId:(uint8_t)sceneId responseHandler:(ResponseHandler)responseHandler
{
    CHIPScenesClusterViewSceneResponseCallbackBridge * onSuccess
        = new CHIPScenesClusterViewSceneResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ViewScene(onSuccess->Cancel(), onFailure->Cancel(), groupId, sceneId);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeSceneCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeSceneCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeCurrentSceneWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeCurrentScene(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeCurrentGroupWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeCurrentGroup(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeSceneValidWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPBooleanAttributeCallbackBridge * onSuccess = new CHIPBooleanAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeSceneValid(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeNameSupportWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeNameSupport(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPSoftwareDiagnostics ()
@property (readonly) Controller::SoftwareDiagnosticsCluster cppCluster;
@end

@implementation CHIPSoftwareDiagnostics

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)resetWatermarks:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ResetWatermarks(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeCurrentHeapHighWatermarkWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt64uAttributeCallbackBridge * onSuccess = new CHIPInt64uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeCurrentHeapHighWatermark(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPSwitch ()
@property (readonly) Controller::SwitchCluster cppCluster;
@end

@implementation CHIPSwitch

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)readAttributeNumberOfPositionsWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeNumberOfPositions(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeCurrentPositionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeCurrentPosition(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)configureAttributeCurrentPositionWithMinInterval:(uint16_t)minInterval
                                             maxInterval:(uint16_t)maxInterval
                                                  change:(uint8_t)change
                                         responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ConfigureAttributeCurrentPosition(
            onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)reportAttributeCurrentPositionWithResponseHandler:(ResponseHandler)reportHandler
{
    CHIPInt8uAttributeCallbackBridge * onReport = new CHIPInt8uAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
    if (!onReport) {
        reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReportAttributeCurrentPosition(onReport->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onReport;
        reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPTvChannel ()
@property (readonly) Controller::TvChannelCluster cppCluster;
@end

@implementation CHIPTvChannel

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)changeChannel:(NSString *)match responseHandler:(ResponseHandler)responseHandler
{
    CHIPTvChannelClusterChangeChannelResponseCallbackBridge * onSuccess
        = new CHIPTvChannelClusterChangeChannelResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ChangeChannel(onSuccess->Cancel(), onFailure->Cancel(),
            chip::ByteSpan((const uint8_t *) [match dataUsingEncoding:NSUTF8StringEncoding].bytes,
                [match lengthOfBytesUsingEncoding:NSUTF8StringEncoding]));
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)changeChannelByNumber:(uint16_t)majorNumber
                  minorNumber:(uint16_t)minorNumber
              responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ChangeChannelByNumber(onSuccess->Cancel(), onFailure->Cancel(), majorNumber, minorNumber);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)skipChannel:(uint16_t)count responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.SkipChannel(onSuccess->Cancel(), onFailure->Cancel(), count);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeTvChannelListWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPTvChannelTvChannelListAttributeCallbackBridge * onSuccess
        = new CHIPTvChannelTvChannelListAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeTvChannelList(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeTvChannelLineupWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], true);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeTvChannelLineup(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeCurrentTvChannelWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], true);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeCurrentTvChannel(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPTargetNavigator ()
@property (readonly) Controller::TargetNavigatorCluster cppCluster;
@end

@implementation CHIPTargetNavigator

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)navigateTarget:(uint8_t)target data:(NSString *)data responseHandler:(ResponseHandler)responseHandler
{
    CHIPTargetNavigatorClusterNavigateTargetResponseCallbackBridge * onSuccess
        = new CHIPTargetNavigatorClusterNavigateTargetResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.NavigateTarget(onSuccess->Cancel(), onFailure->Cancel(), target,
            chip::ByteSpan((const uint8_t *) [data dataUsingEncoding:NSUTF8StringEncoding].bytes,
                [data lengthOfBytesUsingEncoding:NSUTF8StringEncoding]));
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeTargetNavigatorListWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPTargetNavigatorTargetNavigatorListAttributeCallbackBridge * onSuccess
        = new CHIPTargetNavigatorTargetNavigatorListAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeTargetNavigatorList(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPTemperatureMeasurement ()
@property (readonly) Controller::TemperatureMeasurementCluster cppCluster;
@end

@implementation CHIPTemperatureMeasurement

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)readAttributeMeasuredValueWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16sAttributeCallbackBridge * onSuccess = new CHIPInt16sAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeMeasuredValue(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)configureAttributeMeasuredValueWithMinInterval:(uint16_t)minInterval
                                           maxInterval:(uint16_t)maxInterval
                                                change:(int16_t)change
                                       responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ConfigureAttributeMeasuredValue(
            onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)reportAttributeMeasuredValueWithResponseHandler:(ResponseHandler)reportHandler
{
    CHIPInt16sAttributeCallbackBridge * onReport = new CHIPInt16sAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
    if (!onReport) {
        reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReportAttributeMeasuredValue(onReport->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onReport;
        reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeMinMeasuredValueWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16sAttributeCallbackBridge * onSuccess = new CHIPInt16sAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeMinMeasuredValue(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeMaxMeasuredValueWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16sAttributeCallbackBridge * onSuccess = new CHIPInt16sAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeMaxMeasuredValue(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPTestCluster ()
@property (readonly) Controller::TestClusterCluster cppCluster;
@end

@implementation CHIPTestCluster

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)test:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.Test(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)testNotHandled:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.TestNotHandled(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)testSpecific:(ResponseHandler)responseHandler
{
    CHIPTestClusterClusterTestSpecificResponseCallbackBridge * onSuccess
        = new CHIPTestClusterClusterTestSpecificResponseCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.TestSpecific(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)testUnknownCommand:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.TestUnknownCommand(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeBooleanWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPBooleanAttributeCallbackBridge * onSuccess = new CHIPBooleanAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeBoolean(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeBooleanWithValue:(uint8_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeBoolean(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeBitmap8WithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeBitmap8(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeBitmap8WithValue:(uint8_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeBitmap8(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeBitmap16WithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeBitmap16(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeBitmap16WithValue:(uint16_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeBitmap16(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeBitmap32WithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeBitmap32(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeBitmap32WithValue:(uint32_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeBitmap32(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeBitmap64WithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt64uAttributeCallbackBridge * onSuccess = new CHIPInt64uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeBitmap64(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeBitmap64WithValue:(uint64_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeBitmap64(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeInt8uWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeInt8u(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeInt8uWithValue:(uint8_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeInt8u(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeInt16uWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeInt16u(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeInt16uWithValue:(uint16_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeInt16u(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeInt32uWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeInt32u(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeInt32uWithValue:(uint32_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeInt32u(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeInt64uWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt64uAttributeCallbackBridge * onSuccess = new CHIPInt64uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeInt64u(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeInt64uWithValue:(uint64_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeInt64u(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeInt8sWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8sAttributeCallbackBridge * onSuccess = new CHIPInt8sAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeInt8s(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeInt8sWithValue:(int8_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeInt8s(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeInt16sWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16sAttributeCallbackBridge * onSuccess = new CHIPInt16sAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeInt16s(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeInt16sWithValue:(int16_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeInt16s(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeInt32sWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32sAttributeCallbackBridge * onSuccess = new CHIPInt32sAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeInt32s(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeInt32sWithValue:(int32_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeInt32s(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeInt64sWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt64sAttributeCallbackBridge * onSuccess = new CHIPInt64sAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeInt64s(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeInt64sWithValue:(int64_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeInt64s(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeEnum8WithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeEnum8(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeEnum8WithValue:(uint8_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeEnum8(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeEnum16WithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeEnum16(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeEnum16WithValue:(uint16_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeEnum16(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeOctetStringWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], true);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeOctetString(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeOctetStringWithValue:(NSData *)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeOctetString(
            onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) value.bytes, value.length));
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeListInt8uWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPTestClusterListInt8uAttributeCallbackBridge * onSuccess
        = new CHIPTestClusterListInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeListInt8u(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeListOctetStringWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPTestClusterListOctetStringAttributeCallbackBridge * onSuccess
        = new CHIPTestClusterListOctetStringAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeListOctetString(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeListStructOctetStringWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPTestClusterListStructOctetStringAttributeCallbackBridge * onSuccess
        = new CHIPTestClusterListStructOctetStringAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeListStructOctetString(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeLongOctetStringWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], true);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeLongOctetString(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeLongOctetStringWithValue:(NSData *)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeLongOctetString(
            onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) value.bytes, value.length));
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeCharStringWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], false);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeCharString(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeCharStringWithValue:(NSString *)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding];
        err = self.cppCluster.WriteAttributeCharString(
            onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length));
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeLongCharStringWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], false);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeLongCharString(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeLongCharStringWithValue:(NSString *)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        NSData * data = [value dataUsingEncoding:NSUTF8StringEncoding];
        err = self.cppCluster.WriteAttributeLongCharString(
            onSuccess->Cancel(), onFailure->Cancel(), chip::ByteSpan((const uint8_t *) data.bytes, data.length));
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeUnsupportedWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPBooleanAttributeCallbackBridge * onSuccess = new CHIPBooleanAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeUnsupported(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeUnsupportedWithValue:(uint8_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeUnsupported(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPThermostat ()
@property (readonly) Controller::ThermostatCluster cppCluster;
@end

@implementation CHIPThermostat

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)clearWeeklySchedule:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ClearWeeklySchedule(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)getRelayStatusLog:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.GetRelayStatusLog(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)getWeeklySchedule:(uint8_t)daysToReturn modeToReturn:(uint8_t)modeToReturn responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.GetWeeklySchedule(onSuccess->Cancel(), onFailure->Cancel(), daysToReturn, modeToReturn);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)setWeeklySchedule:(uint8_t)numberOfTransitionsForSequence
     dayOfWeekForSequence:(uint8_t)dayOfWeekForSequence
          modeForSequence:(uint8_t)modeForSequence
                  payload:(uint8_t)payload
          responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.SetWeeklySchedule(onSuccess->Cancel(), onFailure->Cancel(), numberOfTransitionsForSequence,
            dayOfWeekForSequence, modeForSequence, payload);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)setpointRaiseLower:(uint8_t)mode amount:(int8_t)amount responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.SetpointRaiseLower(onSuccess->Cancel(), onFailure->Cancel(), mode, amount);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeLocalTemperatureWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16sAttributeCallbackBridge * onSuccess = new CHIPInt16sAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeLocalTemperature(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)configureAttributeLocalTemperatureWithMinInterval:(uint16_t)minInterval
                                              maxInterval:(uint16_t)maxInterval
                                                   change:(int16_t)change
                                          responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ConfigureAttributeLocalTemperature(
            onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)reportAttributeLocalTemperatureWithResponseHandler:(ResponseHandler)reportHandler
{
    CHIPInt16sAttributeCallbackBridge * onReport = new CHIPInt16sAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
    if (!onReport) {
        reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReportAttributeLocalTemperature(onReport->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onReport;
        reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeOccupiedCoolingSetpointWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16sAttributeCallbackBridge * onSuccess = new CHIPInt16sAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeOccupiedCoolingSetpoint(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeOccupiedCoolingSetpointWithValue:(int16_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeOccupiedCoolingSetpoint(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeOccupiedHeatingSetpointWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16sAttributeCallbackBridge * onSuccess = new CHIPInt16sAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeOccupiedHeatingSetpoint(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeOccupiedHeatingSetpointWithValue:(int16_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeOccupiedHeatingSetpoint(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeControlSequenceOfOperationWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeControlSequenceOfOperation(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeControlSequenceOfOperationWithValue:(uint8_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeControlSequenceOfOperation(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeSystemModeWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeSystemMode(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeSystemModeWithValue:(uint8_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeSystemMode(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeStartOfWeekWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeStartOfWeek(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeNumberOfWeeklyTransitionsWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeNumberOfWeeklyTransitions(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeNumberOfDailyTransitionsWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeNumberOfDailyTransitions(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeFeatureMapWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeFeatureMap(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPThreadNetworkDiagnostics ()
@property (readonly) Controller::ThreadNetworkDiagnosticsCluster cppCluster;
@end

@implementation CHIPThreadNetworkDiagnostics

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)resetCounts:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ResetCounts(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeChannelWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeChannel(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeRoutingRoleWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeRoutingRole(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeNetworkNameWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], true);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeNetworkName(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributePanIdWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributePanId(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeExtendedPanIdWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt64uAttributeCallbackBridge * onSuccess = new CHIPInt64uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeExtendedPanId(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeMeshLocalPrefixWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], true);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeMeshLocalPrefix(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeOverrunCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt64uAttributeCallbackBridge * onSuccess = new CHIPInt64uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeOverrunCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeNeighborTableListWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPThreadNetworkDiagnosticsNeighborTableListAttributeCallbackBridge * onSuccess
        = new CHIPThreadNetworkDiagnosticsNeighborTableListAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeNeighborTableList(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeRouteTableListWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPThreadNetworkDiagnosticsRouteTableListAttributeCallbackBridge * onSuccess
        = new CHIPThreadNetworkDiagnosticsRouteTableListAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeRouteTableList(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributePartitionIdWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributePartitionId(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeWeightingWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeWeighting(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeDataVersionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeDataVersion(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeStableDataVersionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeStableDataVersion(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeLeaderRouterIdWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeLeaderRouterId(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeDetachedRoleCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeDetachedRoleCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeChildRoleCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeChildRoleCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeRouterRoleCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeRouterRoleCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeLeaderRoleCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeLeaderRoleCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeAttachAttemptCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeAttachAttemptCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributePartitionIdChangeCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributePartitionIdChangeCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeBetterPartitionAttachAttemptCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeBetterPartitionAttachAttemptCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeParentChangeCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeParentChangeCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeTxTotalCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeTxTotalCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeTxUnicastCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeTxUnicastCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeTxBroadcastCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeTxBroadcastCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeTxAckRequestedCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeTxAckRequestedCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeTxAckedCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeTxAckedCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeTxNoAckRequestedCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeTxNoAckRequestedCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeTxDataCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeTxDataCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeTxDataPollCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeTxDataPollCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeTxBeaconCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeTxBeaconCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeTxBeaconRequestCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeTxBeaconRequestCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeTxOtherCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeTxOtherCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeTxRetryCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeTxRetryCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeTxDirectMaxRetryExpiryCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeTxDirectMaxRetryExpiryCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeTxIndirectMaxRetryExpiryCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeTxIndirectMaxRetryExpiryCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeTxErrCcaCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeTxErrCcaCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeTxErrAbortCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeTxErrAbortCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeTxErrBusyChannelCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeTxErrBusyChannelCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeRxTotalCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeRxTotalCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeRxUnicastCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeRxUnicastCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeRxBroadcastCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeRxBroadcastCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeRxDataCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeRxDataCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeRxDataPollCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeRxDataPollCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeRxBeaconCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeRxBeaconCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeRxBeaconRequestCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeRxBeaconRequestCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeRxOtherCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeRxOtherCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeRxAddressFilteredCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeRxAddressFilteredCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeRxDestAddrFilteredCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeRxDestAddrFilteredCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeRxDuplicatedCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeRxDuplicatedCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeRxErrNoFrameCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeRxErrNoFrameCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeRxErrUnknownNeighborCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeRxErrUnknownNeighborCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeRxErrInvalidSrcAddrCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeRxErrInvalidSrcAddrCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeRxErrSecCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeRxErrSecCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeRxErrFcsCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeRxErrFcsCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeRxErrOtherCountWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt32uAttributeCallbackBridge * onSuccess = new CHIPInt32uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeRxErrOtherCount(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeSecurityPolicyWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPThreadNetworkDiagnosticsSecurityPolicyAttributeCallbackBridge * onSuccess
        = new CHIPThreadNetworkDiagnosticsSecurityPolicyAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeSecurityPolicy(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeChannelMaskWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeChannelMask(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeOperationalDatasetComponentsWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPThreadNetworkDiagnosticsOperationalDatasetComponentsAttributeCallbackBridge * onSuccess
        = new CHIPThreadNetworkDiagnosticsOperationalDatasetComponentsAttributeCallbackBridge(
            responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeOperationalDatasetComponents(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeActiveNetworkFaultsListWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPThreadNetworkDiagnosticsActiveNetworkFaultsListAttributeCallbackBridge * onSuccess
        = new CHIPThreadNetworkDiagnosticsActiveNetworkFaultsListAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeActiveNetworkFaultsList(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPWakeOnLan ()
@property (readonly) Controller::WakeOnLanCluster cppCluster;
@end

@implementation CHIPWakeOnLan

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)readAttributeWakeOnLanMacAddressWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], false);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeWakeOnLanMacAddress(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPWiFiNetworkDiagnostics ()
@property (readonly) Controller::WiFiNetworkDiagnosticsCluster cppCluster;
@end

@implementation CHIPWiFiNetworkDiagnostics

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)resetCounts:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ResetCounts(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeBssidWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPStringAttributeCallbackBridge * onSuccess
        = new CHIPStringAttributeCallbackBridge(responseHandler, [self callbackQueue], true);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeBssid(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeSecurityTypeWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeSecurityType(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeWiFiVersionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeWiFiVersion(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeChannelNumberWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeChannelNumber(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeRssiWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8sAttributeCallbackBridge * onSuccess = new CHIPInt8sAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeRssi(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end

@interface CHIPWindowCovering ()
@property (readonly) Controller::WindowCoveringCluster cppCluster;
@end

@implementation CHIPWindowCovering

- (Controller::ClusterBase *)getCluster
{
    return &_cppCluster;
}

- (void)downOrClose:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.DownOrClose(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)goToLiftPercentage:(uint8_t)liftPercentageValue
    liftPercent100thsValue:(uint16_t)liftPercent100thsValue
           responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.GoToLiftPercentage(
            onSuccess->Cancel(), onFailure->Cancel(), liftPercentageValue, liftPercent100thsValue);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)goToLiftValue:(uint16_t)liftValue responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.GoToLiftValue(onSuccess->Cancel(), onFailure->Cancel(), liftValue);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)goToTiltPercentage:(uint8_t)tiltPercentageValue
    tiltPercent100thsValue:(uint16_t)tiltPercent100thsValue
           responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.GoToTiltPercentage(
            onSuccess->Cancel(), onFailure->Cancel(), tiltPercentageValue, tiltPercent100thsValue);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)goToTiltValue:(uint16_t)tiltValue responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.GoToTiltValue(onSuccess->Cancel(), onFailure->Cancel(), tiltValue);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)stopMotion:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.StopMotion(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}
- (void)upOrOpen:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.UpOrOpen(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeTypeWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeType(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeCurrentPositionLiftWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeCurrentPositionLift(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeCurrentPositionTiltWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeCurrentPositionTilt(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeConfigStatusWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeConfigStatus(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeCurrentPositionLiftPercentageWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeCurrentPositionLiftPercentage(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)configureAttributeCurrentPositionLiftPercentageWithMinInterval:(uint16_t)minInterval
                                                           maxInterval:(uint16_t)maxInterval
                                                                change:(uint8_t)change
                                                       responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ConfigureAttributeCurrentPositionLiftPercentage(
            onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)reportAttributeCurrentPositionLiftPercentageWithResponseHandler:(ResponseHandler)reportHandler
{
    CHIPInt8uAttributeCallbackBridge * onReport = new CHIPInt8uAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
    if (!onReport) {
        reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReportAttributeCurrentPositionLiftPercentage(onReport->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onReport;
        reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeCurrentPositionTiltPercentageWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeCurrentPositionTiltPercentage(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)configureAttributeCurrentPositionTiltPercentageWithMinInterval:(uint16_t)minInterval
                                                           maxInterval:(uint16_t)maxInterval
                                                                change:(uint8_t)change
                                                       responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ConfigureAttributeCurrentPositionTiltPercentage(
            onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)reportAttributeCurrentPositionTiltPercentageWithResponseHandler:(ResponseHandler)reportHandler
{
    CHIPInt8uAttributeCallbackBridge * onReport = new CHIPInt8uAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
    if (!onReport) {
        reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReportAttributeCurrentPositionTiltPercentage(onReport->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onReport;
        reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeOperationalStatusWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeOperationalStatus(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)configureAttributeOperationalStatusWithMinInterval:(uint16_t)minInterval
                                               maxInterval:(uint16_t)maxInterval
                                           responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ConfigureAttributeOperationalStatus(
            onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)reportAttributeOperationalStatusWithResponseHandler:(ResponseHandler)reportHandler
{
    CHIPInt8uAttributeCallbackBridge * onReport = new CHIPInt8uAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
    if (!onReport) {
        reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReportAttributeOperationalStatus(onReport->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onReport;
        reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeTargetPositionLiftPercent100thsWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeTargetPositionLiftPercent100ths(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)configureAttributeTargetPositionLiftPercent100thsWithMinInterval:(uint16_t)minInterval
                                                             maxInterval:(uint16_t)maxInterval
                                                                  change:(uint16_t)change
                                                         responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ConfigureAttributeTargetPositionLiftPercent100ths(
            onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)reportAttributeTargetPositionLiftPercent100thsWithResponseHandler:(ResponseHandler)reportHandler
{
    CHIPInt16uAttributeCallbackBridge * onReport = new CHIPInt16uAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
    if (!onReport) {
        reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReportAttributeTargetPositionLiftPercent100ths(onReport->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onReport;
        reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeTargetPositionTiltPercent100thsWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeTargetPositionTiltPercent100ths(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)configureAttributeTargetPositionTiltPercent100thsWithMinInterval:(uint16_t)minInterval
                                                             maxInterval:(uint16_t)maxInterval
                                                                  change:(uint16_t)change
                                                         responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ConfigureAttributeTargetPositionTiltPercent100ths(
            onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)reportAttributeTargetPositionTiltPercent100thsWithResponseHandler:(ResponseHandler)reportHandler
{
    CHIPInt16uAttributeCallbackBridge * onReport = new CHIPInt16uAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
    if (!onReport) {
        reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReportAttributeTargetPositionTiltPercent100ths(onReport->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onReport;
        reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeEndProductTypeWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeEndProductType(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeCurrentPositionLiftPercent100thsWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeCurrentPositionLiftPercent100ths(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)configureAttributeCurrentPositionLiftPercent100thsWithMinInterval:(uint16_t)minInterval
                                                              maxInterval:(uint16_t)maxInterval
                                                                   change:(uint16_t)change
                                                          responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ConfigureAttributeCurrentPositionLiftPercent100ths(
            onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)reportAttributeCurrentPositionLiftPercent100thsWithResponseHandler:(ResponseHandler)reportHandler
{
    CHIPInt16uAttributeCallbackBridge * onReport = new CHIPInt16uAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
    if (!onReport) {
        reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReportAttributeCurrentPositionLiftPercent100ths(onReport->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onReport;
        reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeCurrentPositionTiltPercent100thsWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeCurrentPositionTiltPercent100ths(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)configureAttributeCurrentPositionTiltPercent100thsWithMinInterval:(uint16_t)minInterval
                                                              maxInterval:(uint16_t)maxInterval
                                                                   change:(uint16_t)change
                                                          responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ConfigureAttributeCurrentPositionTiltPercent100ths(
            onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval, change);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)reportAttributeCurrentPositionTiltPercent100thsWithResponseHandler:(ResponseHandler)reportHandler
{
    CHIPInt16uAttributeCallbackBridge * onReport = new CHIPInt16uAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
    if (!onReport) {
        reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReportAttributeCurrentPositionTiltPercent100ths(onReport->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onReport;
        reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeInstalledOpenLimitLiftWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeInstalledOpenLimitLift(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeInstalledClosedLimitLiftWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeInstalledClosedLimitLift(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeInstalledOpenLimitTiltWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeInstalledOpenLimitTilt(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeInstalledClosedLimitTiltWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeInstalledClosedLimitTilt(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeModeWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt8uAttributeCallbackBridge * onSuccess = new CHIPInt8uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeMode(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)writeAttributeModeWithValue:(uint8_t)value responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.WriteAttributeMode(onSuccess->Cancel(), onFailure->Cancel(), value);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeSafetyStatusWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeSafetyStatus(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)configureAttributeSafetyStatusWithMinInterval:(uint16_t)minInterval
                                          maxInterval:(uint16_t)maxInterval
                                      responseHandler:(ResponseHandler)responseHandler
{
    CHIPDefaultSuccessCallbackBridge * onSuccess = new CHIPDefaultSuccessCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ConfigureAttributeSafetyStatus(onSuccess->Cancel(), onFailure->Cancel(), minInterval, maxInterval);
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)reportAttributeSafetyStatusWithResponseHandler:(ResponseHandler)reportHandler
{
    CHIPInt16uAttributeCallbackBridge * onReport = new CHIPInt16uAttributeCallbackBridge(reportHandler, [self callbackQueue], true);
    if (!onReport) {
        reportHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReportAttributeSafetyStatus(onReport->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onReport;
        reportHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

- (void)readAttributeClusterRevisionWithResponseHandler:(ResponseHandler)responseHandler
{
    CHIPInt16uAttributeCallbackBridge * onSuccess = new CHIPInt16uAttributeCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onSuccess) {
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    CHIPDefaultFailureCallbackBridge * onFailure = new CHIPDefaultFailureCallbackBridge(responseHandler, [self callbackQueue]);
    if (!onFailure) {
        delete onSuccess;
        responseHandler([CHIPError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE], nil);
        return;
    }

    __block CHIP_ERROR err;
    dispatch_sync([self chipWorkQueue], ^{
        err = self.cppCluster.ReadAttributeClusterRevision(onSuccess->Cancel(), onFailure->Cancel());
    });

    if (err != CHIP_NO_ERROR) {
        delete onSuccess;
        delete onFailure;
        responseHandler([CHIPError errorForCHIPErrorCode:err], nil);
    }
}

@end
